I have a scrollview inside a scrollview . The xml is like this
<RelativeLayout ....
<ScrollView.....
<RelativeLayout ....
<Button.....
<Button ....
<ScrollView
<RelativeLayout ....
..........
</RelativeLayout>
</ScrollView>
</RelativeLayout>
</ScrollView>
</RelativeLayout>
in this second scrollview in not scrolling smoothly. can give a solution for that. I tried a lot of solution given in the internet but not working.
NestedScrollView is just like ScrollView , but it supports acting as both a nested scrolling parent and child on both new and old versions of Android. Nested scrolling is enabled by default.
ScrollView is a subclass of FrameLayout , which means that you can place only one View as a child within it; that child contains the entire contents to scroll.
ScrollView is a ViewGroup that make the view hierarchy placed within it scrollable. You may only need to place one other ViewGroup inside it as a child. To add many Views to ScrollView, just directly add them to the child ViewGroup such as: RelativeLayout, LinearLayout….
Try this code. It is working for me`
parentScrollView.setOnTouchListener(new View.OnTouchListener() {
public boolean onTouch(View v, MotionEvent event)
{
findViewById(R.id.childScrollView).getParent().requestDisallowInterceptTouchEvent(false);
return false;
}
});
childScrollView.setOnTouchListener(new View.OnTouchListener() {
public boolean onTouch(View v, MotionEvent event)
{
// Disallow the touch request for parent scroll on touch of
// child view
v.getParent().requestDisallowInterceptTouchEvent(true);
return false;
}
});`
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With