swipRefreshLayout 和Scrollview 以及recycleView嵌套产生滑动冲突问题解决

使用 NestScrollView来替代 ScrollView  可以在滑动到顶部的时候才会出发swip Refreshlayout  那么此时滑动会有点卡顿  那么只能自定义NestScrollView  重写onTouchEvent方法  
 同时 设置
verticalManager.setSmoothScrollbarEnabled(true);
verticalManager.setAutoMeasureEnabled(true);
mRv.setLayoutManager(verticalManager);
mRv.setNestedScrollingEnabled(false);
 
 
重新计算rv的高度
 
 
public class MyRecycleView extends RecyclerView {
    public MyRecycleView(Context context) {
        super(context);
    }

    public MyRecycleView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public MyRecycleView(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
    }

    @Override
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        int expandSpec = MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE >> 2,
                MeasureSpec.AT_MOST);
        super.onMeasure(widthMeasureSpec, expandSpec);
    }
}
这样就可以解决冲突了 
如果是嵌套GridView 只要重写GridView 即可

猜你喜欢

转载自blog.csdn.net/youth_never_go_away/article/details/53930471