Simple. You only need to override scrollview.
Import android. content. context; import android. util. attributeset; import android. view. gesturedetector; import android. view. gesturedetector. simpleongesturelistener; import android. view. motionevent; import android. view. view; import android. widget. scrollview;/** rewrite scrollview * to solve the sliding conflict problem of scrollview nested viewpager * @ date 11:04:22 * @ author zhangyi **/public class myscrollview extends scrollview {private Boolean canscroll; private gesturedetector mgesturedetector; view. ontouchlistener mgesturelistener; Public myscrollview (context, attributeset attrs) {super (context, attrs); mgesturedetector = new gesturedetector (New Role (); canscroll = true ;} @ override public Boolean onintercepttouchevent (motionevent eV) {If (ev. getaction () = motionevent. action_up) canscroll = true; return Super. onintercepttouchevent (EV) & mgesturedetector. ontouchevent (EV);} class extends simpleongesturelistener {@ override public Boolean onscroll (motionevent E1, motionevent E2, float distancex, float distancey) {If (canscroll) if (math. ABS (distancey)> = math. ABS (distancex) canscroll = true; else canscroll = false; return canscroll ;}}}
Use XML to call the custom scrollview Method
Replace the original scrollview component name with the package name. myscrollview.
<com.zy.myview.ScrollView android:layout_width="fill_parent"android:layout_height="wrap_content" android:scrollbars="none" > <LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_gravity="top" android:orientation="vertical" >
........
If you encounter the same problem, try it.