Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to find touch event when finger is swiped over an ImageView
    primarykey
    data
    text
    <p>How to find touch event when finger is swiped over an Image.</p> <p>Relative layout contains multiple image view. they are randomly placed. When I swipe my finger over screen I want to capture image view over which user has crossed his finger.</p> <p>I am able to capture relative layout touch event Please suggest some way to capture image view touched in the swipe action in relative layout.</p> <p>attached image layout for better understanding.</p> <p><img src="https://i.stack.imgur.com/oPxhG.png" alt="enter image description here"></p> <p>CODE:</p> <pre><code>public class MainActivity extends Activity { ImageView imageView; Rect imageViewArea; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); imageView=(ImageView) findViewById(R.id.imageView); imageViewArea = new Rect(); //imageView.getGlobalVisibleRect(imageViewArea); //not working imageView.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { // TODO Auto-generated method stub return false; } }); } //working @Override public boolean onTouchEvent(MotionEvent event) { // TODO Auto-generated method stub switch(event.getActionMasked()) { case MotionEvent.ACTION_DOWN: break; case MotionEvent.ACTION_MOVE: Log.i("log", "ACTION_MOVE"); int x = (int) event.getX(); int y = (int) event.getY(); //not working if(imageViewArea.contains(x, y)) { Toast.makeText(getApplicationContext(), "clicked", Toast.LENGTH_LONG).show(); } break; case MotionEvent.ACTION_UP: break; default: break; } return super.onTouchEvent(event); } </code></pre>
    singulars
    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.
    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