Reference: http://mengsina.iteye.com/blog/1707464
http://fenglog.com/article.asp?id=449
Android ScrollView Nested ScrollView scrolling Problem solving method
Original address: http://trivedihardik.wordpress.com/2011/09/19/scrollview-inside-scrollview-scrolling-problem/
How much of the technology to read e-wen, also do not translate.
While designing rich layouts your might need to use the ScrollView in your app.
Well ideally it not advised to use the ScrollView in a view. So try to avoid it.
Why this problem occurs? :
When you put the ScrollView Android just get confused which scroll view is touched. So sometimes it gets unable to deliver touch event.
But even if the requirement forces and make such layouts. Try this ...
Say case was somewhat like this ....
<ScrollViewAndroid:id= "@+id/parent_scroll"Android:layout_width= "Match_parent"Android:layout_height= "0DP"Android:layout_weight= "1"Android:background= "@color/black"Android:cachecolorhint= "#00000000"Android:fadingedge= "None"Android:overscrollmode= "Never"Android:scrollbars= "None"> <LinearLayoutAndroid:layout_width= "Match_parent"Android:layout_height= "Wrap_content"android:gravity= "Center"android:orientation= "vertical"> <ScrollViewAndroid:id= "@+id/child_scroll"Android:layout_width= "Match_parent"Android:layout_height= "Wrap_content"Android:layout_torightof= "@+id/textview001"Android:cachecolorhint= "#00000000"Android:fadingedge= "None"Android:overscrollmode= "Never"Android:scrollbars= "None"> <TextViewAndroid:id= "@+id/tv_detail"Android:layout_width= "Match_parent"Android:layout_height= "Wrap_content"android:padding= "15DP"Android:textcolor= "@color/cbwhite"android:textsize= "@dimen/cb_textsize_big"/> </ScrollView> </LinearLayout> </ScrollView>
Step 1:provide Unique ID to both the ScrollView.
Step 2:get Reference of that, scrollview in your activity.
ScrollView Parentscroll = (ScrollView) Findviewbyid (r.id.parent_scroll); = (ScrollView) Findviewbyid (R.id.child_scroll);
Step 3:now Set touch listeners for both.
Parentscroll.setontouchlistener (NewView.ontouchlistener () { Public BooleanOnTouch (View V, motionevent event) {Findviewbyid (r.id.child_scroll). GetParent (). Requestdisallowinterc Epttouchevent (false); return false; } }); Childscroll.setontouchlistener (NewView.ontouchlistener () { Public BooleanOnTouch (View V, motionevent event) {//Disallow the touch request for parent scroll on Touch of child viewV.getparent (). Requestdisallowintercepttouchevent (true); return false; } });
Done ...
Android ScrollView Nested ScrollView scrolling Problem solving method