Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Scrollview inside a scrollview in android issue

Tags:

android

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.

like image 563
Nithinlal Avatar asked Jul 16 '13 08:07

Nithinlal


People also ask

What is nested scroll view in Android?

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.

How many views can you use within a ScrollView?

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.

Can we use ScrollView in RelativeLayout in Android?

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….


1 Answers

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;
}
});`
like image 68
Deepthi Avatar answered Oct 21 '22 04:10

Deepthi