I\'m new to android and I want to know how to identify the hover view when moving finger on different views. As a example if my activity has 5 LinearLayouts A,B,C,D,E and if
Implement View.OnTouchListener in your activity
get rect area of item touch then if touch points are inside the that rectangle area then do something...
@Override
public void onWindowFocusChanged(boolean hasFocus) {
super.onWindowFocusChanged(hasFocus);
rect1 = new Rect(linearLayout1.getLeft(), linearLayout1.getTop(),
linearLayout1.getRight(), linearLayout1.getBottom());
rect2= new Rect(linearLayout2.getLeft(), linearLayout2.getTop(),
linearLayout2.getRight(), linearLayout2.getBottom());
}
/////////////////////////////
@Override
public boolean onTouch(View v, MotionEvent event) {
if (event.getActionMasked() == (MotionEvent.ACTION_DOWN|MotionEvent.ACTION_MOVE)) {
if (rect1.contains((int) event.getX(), (int) event.getY())) {
//do something when touch or moving on linearlayout1 area
} else if (rect2.contains((int) event.getX(), (int) event.getY())) {
//do something when touch or moving on linearlayout2 area
}
}
return true;
}