滑动冲突问题有好几种方法解决,这里介绍最简单的一种:
禁止RecyclerView滑动
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this){
@Override
public boolean canScrollVertically() {
return false;//禁止滑动
}
};
但是这样在高版本手机上都会只显示有限的几个item,并不能显示完所有,需要在使用 RelativeLayout
包裹 RecyclerView,并设置android:descendantFocusability="blocksDescendants"
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:descendantFocusability="blocksDescendants">
<android.support.v7.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/recyclerview"
android:padding="10dp"
android:layout_margin="15dp"
android:background="@color/white"/>
</RelativeLayout>
至于android:descendantFocusability="blocksDescendants"属性
参考https://www.cnblogs.com/eyu8874521/archive/2012/10/17/2727882.html