[英]Flutter: How to make TextView in Listview fill remaining space
[英]How can I make the footer of a ListView stretch to fill the remaining space?
我有一個ListView,可以包含任意數量的項目。 當它使用小於屏幕的整個高度時,我想顯示一個填充剩余空間的頁腳。
頁腳只是一個平鋪圖像。 我不能將它設置為ListView或其容器的背景,因為列表項是部分透明的,它必須是主背景,而不是通過它們可見的頁腳。
如果頁腳具有固定高度,則添加頁腳視圖可正常工作,但如果固定高度大於剩余高度,則ListView會不必要地滾動。
使頁腳視圖fill_parent似乎沒有效果,它只是不可見。
將頁腳視圖放入父布局也沒有任何效果,因為ListView似乎填充整個高度,除非給定一個固定的layout_height值。
這可能嗎?
嘗試將布局權重設置為1,或者檢查嘗試合並視圖: http : //android-developers.blogspot.com/2009/03/android-layout-tricks-3-optimize-by.html
將ListView放在另一個布局中設置展開以填充屏幕。
LinearLayout最適合這種情況。
像這樣的東西:
<LinearLayout android:layout_height="match_parent"
android:layout_width="match_parent" >
<ListView android:layout_height="match_parent"
android:layout_width="match_parent" >
...
</ListView>
</LinearLayout>
這應該將LinearLayout填充到屏幕的底部。 您可以使用此行為來控制View的外觀。
希望這可以幫助!
試試這個並告訴我它是否有效:
android:layout_hight="wrap_content"
android:layout_hight="fill_parent"
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.