外层scrollview重兄信帆写一下,当滑动内层scrollview的时候就不让外层的scrollview滑动.
public class MyScrollView extends ScrollView {
private boolean canScroll;
private GestureDetector mGestureDetector;
View.OnTouchListener mGestureListener;
public MyScrollView(Context context, AttributeSet attrs) {
super(context, attrs);
mGestureDetector = new GestureDetector(context, new YScrollDetector());
canScroll = true;
}
@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
if(ev.getAction() == MotionEvent.ACTION_UP)
canScroll = true;
return super.onInterceptTouchEvent(ev) && mGestureDetector.onTouchEvent(ev);
}
public 羡雹class YScrollDetector 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;
}
}
}