例如:
/** * @ClassName: MyScrollView.java * @Description: * @author iaiai [email protected] * @date 2015-1-1 下午5:43:12 */ public class MyScrollView extends ScrollView { public MyScrollView(Context context) { super(context); } public MyScrollView(Context context, AttributeSet attrs) { super(context, attrs); } public MyScrollView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); } @Override public boolean onInterceptTouchEvent(MotionEvent event) // 这个方法如果返回 true 的话 // 两个手指移动,启动一个按下的手指的移动不能被传播出去。 { super.onInterceptTouchEvent(event); return false; } @Override public boolean onTouchEvent(MotionEvent event)// 这个方法如果 true 则整个Activity 的 // onTouchEvent() 不会被系统回调 { super.onTouchEvent(event); return false; } }
自定义了以上代码之后我们就可以在布局xml中编写