-1
我想垂直設置兩個Listviews。
我希望它們分別是垂直屏幕長度的40%和60%。有兩個ListViews的佈局權重
下面是代碼:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:weightSum="1">
<LinearLayout
android:layout_weight="0.4"
android:layout_width="match_parent"
android:layout_height="0dp">
<ListView
android:id="@android:id/list"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
</LinearLayout>
<LinearLayout
android:layout_weight="0.6"
android:layout_width="match_parent"
android:layout_height="0dp">
<ExpandableListView
android:id="@+id/listEvents"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
</LinearLayout>
</LinearLayout>
但是,這是行不通的。
第一個ListView需要所有的屏幕。
我也嘗試刪除嵌入兩個ListViews的LinearLayout,但它也沒有工作。 我也試過用android:layout_height =「wrap_content」在兩個Listviews中都沒有工作。
如果我將屏幕旋轉到橫向,並且再次返回到端口後,它將起作用。
創建第一個實例失敗。
關於如何解決它的任何想法?