Android的2列表视图垂直使用50%的屏幕高度的-50% [英] Android two listview vertically using 50%-50% of the screen height
本文介绍了Android的2列表视图垂直使用50%的屏幕高度的-50%的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
喜 我想用两个列表视图在一个屏幕垂直方向一个在另一个下面,也是这两个列表视图同样采取50%的画面-50%。我的问题是,我创建的布局,在eclipse(图形布局)看起来不错,但在设备中,它不会把屏幕的一半。这似乎取决于列表视图的内容。我怎么能这样做的权利?
Hi I would like to use two listviews in one screen vertically one below the other and also the two listview equally take 50%-50% of the screen. My problem is, i created the layout, in eclipse (graphical layout ) looks great but in the device it wont take the half of the screen. It seems depends of the content of the listview. How can i do it right ??
<?xml version="1.0" encoding="utf-8"?>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5dip"
android:textSize="18sp"
android:textStyle="bold"
android:gravity="left"
android:textColor="#000"
android:text="Some Text" />
<ListView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginLeft="10dip"
android:layout_marginRight="10dip"
android:layout_weight="0.5"
android:background="#FB0"
android:scrollbars="none"
android:dividerHeight="2dip" />
<ListView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginLeft="10dip"
android:layout_marginRight="10dip"
android:layout_weight="0.5"
android:background="#FB0"
android:scrollbars="none"
android:dividerHeight="2dip" />
推荐答案
您应该出台的LinearLayout
和使用 layout_weight
,同时设定 layout_height =0dp
。
You should introduce LinearLayout
and use layout_weight
, while setting layout_height="0dp"
.
下面是一个例子:
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ListView
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="0.5" />
<ListView
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="0.5" />
</LinearLayout>
这篇关于Android的2列表视图垂直使用50%的屏幕高度的-50%的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文