How to stop parent scroll scrolling when scroll scrolling scrolls in android?

I know that we can use touchlisteners to view scrolls, for example

parentScrollView.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { Log.v(TAG, "PARENT TOUCH"); findViewById(R.id.child_scroll).getParent() .requestDisallowInterceptTouchEvent(false); return false; } }); childScrollView.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { Log.v(TAG, "CHILD TOUCH"); // Disallow the touch request for parent scroll on touch of child view v.getParent().requestDisallowInterceptTouchEvent(true); return false; } }); 

What I came across is my child’s scroll profile, not the immediate child in the parent scroll. In this, v.getParent() does not work, and when I touch and try to scroll the scroll of my child scroll, the scroll of the entire main scroll.

The positions of my scroll views in my layout (views are dynamically created, so I need to go with so many layouts)

 linearLayout ParentscrollView(0) linearLayout(0) relativeLayout(0) TextView(0) relativeLayout(1) childScrollView(0) 

need help. Thanks in advance.!!

+6
source share
1 answer

Does findViewById() not work for parent scroll name?

 childScrollView.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { Log.v(TAG, "CHILD TOUCH"); // Disallow the touch request for parent scroll on touch of child view findViewById(parentLayouttId).requestDisallowInterceptTouchEvent(true); return false; } }); 
+6
source

Source: https://habr.com/ru/post/986035/


All Articles