Guest User

Untitled

a guest
Jul 17th, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. private Rect rect; // Variable rect to hold the bounds of the view
  2.  
  3. public boolean onTouch(View v, MotionEvent event) {
  4. if(event.getAction() == MotionEvent.ACTION_DOWN){
  5. // Construct a rect of the view's bounds
  6. rect = new Rect(v.getLeft(), v.getTop(), v.getRight(), v.getBottom());
  7.  
  8. }
  9. if(event.getAction() == MotionEvent.ACTION_MOVE){
  10. if(!rect.contains((int)event.getX(), (int)event.getY())){
  11. // User moved outside bounds
  12. }
  13. }
  14. return false;
  15. }
Add Comment
Please, Sign In to add comment