Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private Rect rect; // Variable rect to hold the bounds of the view
- public boolean onTouch(View v, MotionEvent event) {
- if(event.getAction() == MotionEvent.ACTION_DOWN){
- // Construct a rect of the view's bounds
- rect = new Rect(v.getLeft(), v.getTop(), v.getRight(), v.getBottom());
- }
- if(event.getAction() == MotionEvent.ACTION_MOVE){
- if(!rect.contains((int)event.getX(), (int)event.getY())){
- // User moved outside bounds
- }
- }
- return false;
- }
Add Comment
Please, Sign In to add comment