实现功能:RecyclerView外层套着ScrollView,使RecyclerView完全展示数据。
实际上ScrollView嵌套RecyclerView,RecyclerView中的数据不会全部展示,显示一行或者两行等情况。
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/color_ffffff"
android:orientation="vertical"
android:scrollbars="none">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<android.support.v7.widget.RecyclerView
android:id="@+id/setting_info_rlv"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:focusableInTouchMode="false"
android:scrollbars="none" />
</LinearLayout>
</ScrollView>
解决方案:直接给RecyclerView外嵌套一个布局RelativeLayout,再给RelativeLayout设置 属性android:descendantFocusability="blocksDescendants"
<RelativeLayout
android:id="@+id/setting_info_ll_photo"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.RecyclerView
android:id="@+id/setting_info_rlv"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:focusableInTouchMode="false"
android:scrollbars="none" />
</RelativeLayout>
最后:recyclerview.setnestedscrollingenabled(
false);
//禁止recyclerView嵌套滑动