android 设置view最大高度,android-在RecyclerView上设置最大高度
我有一個對話框片段,其中包含線性布局,其中涉及RecyclerView上方的titleText,在最底部,recyclerView下方有一個按鈕.
由于recyclerView根據適配器設置的項目數展開或折疊,因此按鈕有時會被截斷并且不再顯示在屏幕上,因為recyclerView僅覆蓋整個屏幕.
我的問題是,有沒有一種方法可以設置recyclerView的最大高度,而無需隱藏下面的按鈕.我也不想只是給視圖一個隨機的高度,以防萬一recyclerView不包含任何項目,而這只是一個空白部分.
如果您遇到過此問題,以及如何解決此問題,請告訴我.謝謝!
解決方法:
更新
您可以使用布局權重輕松實現此目的.這是一個例子:
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="Title"
android:textSize="21sp"/>
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="30dp">
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:text="Submit"/>
Title和RecyclerView將根據內容包裝內容,而按鈕將始終占據底部.
標簽:android-recyclerview,android-layout,android
來源: https://codeday.me/bug/20191026/1938097.html
總結
以上是生活随笔為你收集整理的android 设置view最大高度,android-在RecyclerView上设置最大高度的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 国产方德桌面操作系统5.0发布:适配10
- 下一篇: 导演谈《雷神4》锤哥裸身秀肌肉:好身材不