Android 6.0 解决Recyclerview 在 Scrollview 中不能高度自适应问题
2016-10-17 20:32
736 查看
Android 6.0 解决Recyclerview 在 Scrollview 中不能高度自适应问题
在项目中遇到解决Recyclerview 在 Scrollview 中不能高度自适应问题:android6.0以下机器是可以的,但是6.0就不能自适应,经网上查询应该是一个bug。在网上查询资料终于找到解决方法
http://stackoverflow.com/questions/27083091/recyclerview-inside-scrollview-is-not-working
其他网站重写LayoutManager的方法试了都不行。
最终解决办法很简单,如下:
在 recyclerview 外面再嵌套一层 RelativeLayout即可。
代码 如下:
xml
<RelativeLayout android:layout_width="match_parent" android:layout_height="match_parent" android:descendantFocusability="blocksDescendants"> <android.support.v7.widget.RecyclerView android:id="@+id/recyclerView_image" android:layout_width="match_parent" android:layout_height="match_parent" android:choiceMode="singleChoice" android:divider="@null" android:fadingEdge="none" android:listSelector="@android:color/transparent" android:padding="@dimen/margin_horizontal_mid" android:scrollbarStyle="outsideOverlay" app:layoutManager="android.support.v7.widget.GridLayoutManager" app:spanCount="4" tools:listitem="@layout/adapter_repair_image_list_item" /> </RelativeLayout>
activity:
private void initWidget() { selImageList = new ArrayList<>(); adapter = new ImagePickerAdapter(this, selImageList, maxImgCount); adapter.setOnItemClickListener(this); mRecyclerViewImage.setLayoutManager(new GridLayoutManager(this, 4)); mRecyclerViewImage.setHasFixedSize(true); mRecyclerViewImage.setAdapter(adapter); }
以上方法亲测可用。
相关文章推荐
- Android 6.0 解决recyclerview 在 scrollview 中不能全部显示,高度不正常的问题
- Android 6.0 解决recyclerview 在 scrollview 中不能全部显示,高度不正常的问题。
- Android 6.0以上 解决recyclerview 在 scrollview 中不能全部显示,高度不正常的问题
- Android 6.0 解决recyclerview 在 scrollview 中不能全部显示,高度不正常的问题。
- Android 6.0 解决recyclerview 在 scrollview 中不能全部显示,高度不正常的问题
- Android 6.0 解决recyclerview 在 scrollview 中不能全部显示,高度不正常的问题
- Android 6.0 解决recyclerview 在 scrollview 中不能全部显示,高度不正常的问题
- Android 6.0 解决recyclerview 在 scrollview 中不能全部显示,高度不正常的问题
- Android 6.0 解决recyclerview 在 scrollview 中不能全部显示,高度不正常的问题。
- Android 6.0 解决recyclerview 在 scrollview 中不能全部显示,高度不正常的问题
- Android 6.0 scrollview 嵌套recyclerview不能全部显示,高度不正常的问题
- Android 6.0 ScrollView嵌套RecyclerView高度自适应问题
- Android 6.0 scrollview 嵌套recyclerview不能全部显示,高度不正常的问题
- 解决Scrollview 嵌套recyclerview不能显示,高度不正常的问题
- 解决Scrollview 嵌套recyclerview不能显示,高度不正常的问题
- 解决 scrollview嵌套recyclerview 中不能滑动,高度不正常的问题。
- 解决recyclerview 在 scrollview 中不能全部显示,高度不正常的问题
- 解决Scrollview 嵌套recyclerview不能显示,高度不正常的问题
- 解决Scrollview 嵌套recyclerview不能显示,高度不正常的问题
- RecylerViewd的Item高度自适应,Scrollview 嵌套 RecyclerView 及在Android 5.1版本滑动时 惯性消失问题