I'm using RecylerView
in my Android app, for each row, I used 1 line for Text and 1 line for containing 3 buttons. The problem is: if I hold the position in the region of buttons and drag UP/DOWN,
RecylerView
does not scroll. But if I hold and drag other positions (Not in region of buttons), It scrolls normally.
public static boolean inRegion(float x, float y, View v) {
int[] location = new int[8];
v.getLocationOnScreen(location);
return location[0] + v.getWidth() > x && location[1] + v.getHeight() > y
&& location[0] < x && location[1] < y;
}
public static View getMapView(ViewGroup viewGroup) {
View mapView = null;
int size = viewGroup.getChildCount();
for (int i = 0; i < size; i++) {
View view = viewGroup.getChildAt(i) ;
if (view.getTag() != null && view.getTag() instanceof String) {
String tag = (String) view.getTag();
if (tag.equals("MapView"))
return view;
}
if (view instanceof ViewGroup) {
mapView = getMapView((ViewGroup) view);
if (mapView != null)
break;
}
}
return mapView;
}
@Override
public boolean onInterceptTouchEvent(MotionEvent event) {
long start = System.currentTimeMillis();
View view = getMapView(this);
boolean r = false;
if (view != null) {
r = inRegion(event.getRawX(), event.getRawY(), view);
}
if (r == false)
return super.onInterceptHoverEvent(event);
else
return false;
}
How can I fix this?