I\'m trying to put a ScrollView inside another ScrollView and I tried the answers found on this site but it still doesn\'t seems to work completely. Here is the XML:
I use RectF to test whether you finger locates in the range of your child_view.
I've used it for a case that a mix between scrollview and viewpager(that contains two pages with recycleviews).
Try these codes and you will get what you wanna.
findViewById(R.id.parent_view).setOnTouchListener(new View.OnTouchListener() {
public boolean onTouch(View v, MotionEvent event) {
View childV = findViewById(R.id.child_view);
if (childV != null) {
int[] l = new int[2];
childV.getLocationOnScreen(l);
RectF rect = new RectF(l[0], l[1], l[0] + childV.getWidth(), l[1] + childV.getHeight());
if(rect.contains( event.getX(), event.getY())) {
childV.getParent()
.requestDisallowInterceptTouchEvent(false);
childV.onTouchEvent(event);
return true;
}
}
childV.getParent()
.requestDisallowInterceptTouchEvent(true);
return false;
}
});