Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>What I understood from the question is, You have an image view and where ever we touches upon the image, you need a text there. <br> I done this using <code>FrameLayout</code>.</p> <p>First of all, I wrapped the ImageView with a FrameLayout as</p> <pre><code>&lt;FrameLayout android:id="@+id/frameLayout1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@+id/imageView1" android:layout_marginTop="98dp" &gt; &lt;ImageView android:id="@+id/imageView2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="38dp" android:src="@drawable/old1" /&gt; &lt;/FrameLayout&gt; </code></pre> <p>This is not a must, to be a FrameLayout. <strong>Just wrap the image with some layout</strong>.</p> <p>Then inside MainActivity, I done as</p> <pre><code>public class MainActivity extends Activity { FrameLayout layout; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); layout=(FrameLayout) findViewById(R.id.frameLayout1); layout.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { int x=(int) event.getX(); int y=(int) event.getY(); Log.d("Nzm", "x="+x+"y="+y); FrameLayout mFrame=new FrameLayout(MainActivity.this); TextView tv=new TextView(MainActivity.this); if(x!=0 &amp;&amp; y!=0) { FrameLayout.LayoutParams mParams=new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); mFrame.setLayoutParams(mParams); mFrame.setPadding(x, y, 0, 0); tv.setLayoutParams(mParams); tv.setText("Tooltip"); mFrame.addView(tv); layout.addView(mFrame); } return true; } }); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload