Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I have used dispatchTouchEvent(MotionEvent ev) as required. Here is the solution.</p> <pre><code>private boolean isInSideClicked = false; public boolean dispatchTouchEvent(MotionEvent event) { if(event.getAction() == MotionEvent.ACTION_DOWN) { View content = findViewById(R.id.textView1); int[] contentLocation = new int[2]; content.getLocationOnScreen(contentLocation); Rect rect = new Rect(contentLocation[0], contentLocation[1], contentLocation[0] + content.getWidth(), contentLocation[1] + content.getHeight()); View frame = findViewById(R.id.editText1); int[] frameLocation = new int[2]; frame.getLocationOnScreen(frameLocation); Rect framerect = new Rect(frameLocation[0], frameLocation[1], frameLocation[0] + frame.getWidth(), frameLocation[1] + frame.getHeight()); Log.d(TAG, "rect: "+rect.bottom+" , "+rect.top+" , "+rect.left+" , "+rect.right); Log.d(TAG, "FrameRect: "+framerect.bottom+" , "+framerect.top+" , "+framerect.left+" , "+framerect.right); Log.d(TAG, "x: "+event.getX()+" y: "+event.getY()); if((rect.contains((int)event.getX(), (int)event.getY()) || framerect.contains((int)event.getX(), (int)event.getY()) ) ) { isInSideClicked = true; } if(isInSideClicked){ return super.dispatchTouchEvent(event); }else{ return true; } }else if(event.getAction() == MotionEvent.ACTION_UP &amp;&amp; isInSideClicked) { isInSideClicked = false; return super.dispatchTouchEvent(event); }else if(event.getAction() == MotionEvent.ACTION_MOVE &amp;&amp; isInSideClicked) { return super.dispatchTouchEvent(event); }else{ isInSideClicked = false; return true; } } </code></pre> <p>Below is the hierarchy on how the touch event is processed by OS level.</p> <pre><code>Activity.dispatchTouchEvent() ViewGroup.dispatchTouchEvent() View.dispatchTouchEvent() View.onTouchEvent() ViewGroup.onTouchEvent() Activity.onTouchEvent() </code></pre> <p>With this I have restricted the touch events of the views which are not in required layouts/views.</p>
    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