您的位置:首页 > 其它

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

2016-12-29 17:15 429 查看
使用 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 即可
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐