0
我有一个线性布局,有两个列表视图,一个文本视图和另一个线性布局来容纳一些按钮。我希望第二个listview的高度是第一个的两倍。我已经设置的两个列表视图0dp高度并且给了第一1:1的layout_weight和的2的第二权重,并且然后设置weightSum含视图的至3下面是实际的布局:layout_weight在模拟器中工作,而不是在设备上
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:weightSum="3"
android:layout_height="match_parent">
<ListView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:id="@+id/categoryList" />
<ListView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="2"
android:id="@+id/itemList" />
<TextView
android:id="@+id/walletStr"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<Button
android:id="@+id/cancelBtn"
android:text="cancel"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<Button
android:id="@+id/buyBtn"
android:text="buy"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
</LinearLayout>
在模拟器上,这会产生所需的效果,但在实际设备上,几乎所有空间都会进入顶部列表视图。
任何想法?提前致谢。
删除'LinearLayout'外部'weightSum'属性。 –