美文网首页
安卓中View的滑动冲突

安卓中View的滑动冲突

作者: mFrankHon | 来源:发表于2018-04-16 00:05 被阅读0次

外部拦截
重写ViewGroup的onInterceptTouchEvent()方法
内部拦截

public boolean dispatchTouchEvent(MotionEvent event){
  switch(event.getAction()){
        case MotionEvent.ACTION_DOWN:
          parent.requestDisallowInterceptTouchEvent(true);//父元素不拦截
        break;
        default:
        break;
    }
}

??待测??

    @Override  
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {  
        int expandSpec = MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE >> 2,  //表示父布局给的参考的大小无限大。(listview无边界)
                MeasureSpec.AT_MOST);  
        super.onMeasure(widthMeasureSpec, expandSpec);  
    }  

相关文章

网友评论

      本文标题:安卓中View的滑动冲突

      本文链接:https://www.haomeiwen.com/subject/rmzjkftx.html