我的需求
RecyclerView嵌套多布局,前两个布局正常显示,最后一个布局不正常显示。开始排错
网上查询了一些资料:
第一种解决方案:
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:descendantFocusability="beforeDescendants">
<android.support.v7.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</RelativeLayout>
说是给 RecyclerView 外层嵌套一个RelativeLayout 里面加
android:descendantFocusability="beforeDescendants"
属性,后来加上测试不通过,我的问题并没有解决。
第二种解决方案:
嵌套NestedScrollView使用,并设置android:overScrollMode="never"
属性可以解决,但是我发现新的问题,底部会有无限的空白。
最终解决方案是把第三个ItemType的跟布局的高设置 android:layout_height="wrap_content"
问题解决。
我们开发的时候难免会粗心,无法发现细微的问题,遇见这个情况静下心来一点点找方法排问题,一定会发现问题的根源,我们人生始终是在创造问题,始终又在解决问题。