解决ScrollView嵌套RecyclerView时item显示不全的问题
16lz
2021-01-22
问题:ScrollView嵌套RecyclerView时,RecyclerView的item显示不全
第一种方法:在RecyclerView的外层套一层相对布局RelativeLayout并设置:android:descendantFocusability="blocksDescendants"属性。
例如:<RelativeLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:descendantFocusability="blocksDescendants"> <android.support.v7.widget.RecyclerView android:id="@+id/rv_list" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margin="20dp"> </android.support.v7.widget.RecyclerView> </RelativeLayout>不过此种方法在上下滑动时如果手指滑动区域在RecyclerView区域内会有粘稠感滑动不流畅。
第二种方法:在xml布局文件中将ScrollView替换成android.support.v4.widget.NestedScrollView,并在java代码中设置recyclerView.setNestedScrollingEnabled(false);属性。
更多相关文章
- Android自定义View-----上下拖动布局--SlideContentLayout
- 图形布局和实际设备上的布局不同
- Android 软键盘弹出时把原来布局顶上去的解决方法
- Java记录 -88- 利用反射机制调用对象的私有方法和属性
- 包含带标记的值的XML属性文件
- JAVA中的反射只获取属性的get方法
- 如何在Spring中读取具有相同键的多个属性?
- 为泛型类的泛型方法的属性赋值 - Java
- 如何在Spring Data(JPA)派生查询中按多个属性排序?