[英]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.