[英]Android ListView not scaling properly
我是android編程的新手,遇到了我無法解決的問題。 我用谷歌搜索了一段時間,但沒有找到解決方案。 據我了解,Android中的ListView正在根據屏幕上的空間采用其大小,但是如果我需要更多空間該怎么辦。
我在圖片上有下面的布局,問題是第二個ListView只有一個大項目,然后您需要滾動,但我希望它至少是幾個(可見-非滾動)項目。 我不希望它達到固定的高度。 但是,即使我這樣做了,它仍然超出了可見區域,這迫使我制作了一個ScrollView,它再次不適用於ListViews。
所以我很迷路。 請指導
您可以將兩個帶有權重的列表視圖放入LinearLayout中。 參見第二張圖片: http : //android4beginners.com/wp-content/uploads/2013/07/android_studio_linear_layout_example.png
您需要做的就是根據要尋找的設計設置列表視圖的權重。
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/main_rel"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:weightSum="2.0" >
<ListView
android:id="@+id/child_one"
android:layout_width="match_parent"
android:layout_height="0"
android:layout_weight="1.0"
android:background="#0000FF" >
</ListView>
<ListView
android:id="@+id/child_two"
android:layout_width="match_parent"
android:layout_height="0"
android:layout_weight="1.0"
android:background="#00FF00" >
</ListView>
</LinearLayout>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.