Android學習—解決ListView部分內容被Tabhost遮蓋問題
阿新 • • 發佈:2020-10-21
問題:tabhost固定在底部,某個tab中存在Listview,執行起來後發現如果listview中的列表內容比較多(超過一屏時),就會出現部分內容被tabhost遮蓋了。
原Listview佈局檔案
<ListView android:id="@+id/listBudgetSet" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginLeft="4dp" android:layout_marginRight="4dp"> </ListView>
後來經過多次除錯,發現可以通過配置Listview解決這個問題,下面是重新配置listview的:
在<ListView>中加上android:layout_weight="1" ,並且在listview的下方加一個佈局,這是用於留出tabhost顯示的空間(也就是讓listview的滾動條增長70dp)
<ListView android:id="@+id/listBudgetSet" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginLeft="4dp" android:layout_marginRight="4dp" android:layout_weight="1"> </ListView> <LinearLayout android:id="@+id/budgetLT" android:orientation="horizontal" android:layout_width="match_parent" android:layout_height="70sp"> </LinearLayout>
重新設定後,滾動條明顯b變長了,下方被遮蓋的也顯示出來了,問題解決~~~
不過在程式碼那邊我也有做處理,為了是讓這個介面適用不同的oncreate入口,就需要判斷隱藏或顯示listview下方的佈局,這裡就不貼程式碼了,定義一個全域性靜態變數,控制LinearLayout顯示或隱藏就ok了。
轉載於:https://blog.51cto.com/alany/1587855