在最近项目中遇到 ,在RecyclerView加载list数据时,高度无法自适应增长,看了很多博客,各种尝试,都没有解决这个问题,在某个博客中,讲到此解决方法,在此记录下。
即在RecyclerView 布局时用 RelativeLayout 包裹着,即:
<RelativeLayout android:layout_width="match_parent" android:layout_height="match_parent" android:background="@color/white" android:orientation="vertical" > <android.support.v7.widget.RecyclerView android:id="@+id/id_rv_orders" android:layout_width="match_parent" android:layout_height="match_parent" /> </RelativeLayout>
就可以自适应item数量高度
本文介绍了一种在使用RecyclerView加载list数据时,实现高度自适应的方法。通过将RecyclerView包裹在RelativeLayout中,并设置其宽高为match_parent,可以使得RecyclerView根据item数量自动调整高度。
1732

被折叠的 条评论
为什么被折叠?



