[英]Adjust items height to fit its RecyclerView according to screen size
我有一个带有height:match_parent的RecyclerView
,它在适配器中以固定的高度垂直显示16个项目。 一切工作正常,除非涉及到不同的屏幕尺寸。 在大屏幕中,显示16个项目后,底部会保留一个空间,在小屏幕手机上,该位置正好适合底部。 我正在寻找一种方法,将列表项的高度调整到RecyclerView
高度,直到最后没有滚动。
查看下面的屏幕截图以获取更多说明
问题:
期望:
我的方法是将Item的权重设置为1,因此当渲染到RecyclerView
16次时,它们将在RecyclerView
共享相同的高度。 不幸的是,这对我没有用。
我的RecyclerView:
<android.support.v7.widget.RecyclerView
android:id="@+id/rv_morning"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:overScrollMode="never" />
我的适配器:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@color/white"
android:clickable="false"
android:orientation="vertical">
<TextView />
</LinearLayout>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.