Android嵌套问题:ScrollView嵌套RecyclerView完全展示
2018-03-07 12:49
429 查看
实现功能: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"
实际上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嵌套滑动
相关文章推荐
- Android的ScrollView下嵌套GridView显示不完全问题处理
- Android 7.0手机HorizontalScrollView嵌套RecyclerView展示不完全问题
- android 关于 ScrollView嵌套GridView,ListView 显示和滑动的问题
- android 关于 ScrollView嵌套GridView,ListView 显示和滑动的问题
- 完美解决android:ScrollView嵌套ListView的问题 .
- android:ScrollView嵌套ListView的问题
- Android学习 之 问题&解答 ScrollView中嵌套ListView时显示不全的简便解决方案
- [android] ScrollView 嵌套 ListView GridView问题
- Android ScrollView中嵌套ListView滚动效果冲突问题解决
- 【Android】嵌套Fragment无法接收onCreateOptionsMenu事件的问题
- Android-ListView中嵌套(ListView)控件时item的点击事件不起作用的问题
- Android 关于在ScrollView中加上一个ListView,ListView内容显示不完全(总是显示第一项)的问题的两种简单的解决方案
- [Android开发常见问题-23] Android Handler、Message完全解析,带你从源码的角度彻底理解
- android软键盘挡住输入框问题 完全解决
- android 关于 ScrollView嵌套GridView,ListView 显示和滑动的问题
- Android-ListView中嵌套(ListView)控件时的问题
- Android完全退出程序问题综述
- Android嵌套布局时覆盖问题的解决
- 【Android】嵌套Fragment无法接收onCreateOptionsMenu事件的问题
- android 关于 ScrollView嵌套GridView,ListView 显示和滑动的问题