Android表格布局宽度问题
我必须制作一个布局,其中第一行有一个标题,在其下方有列表视图。标题应左对齐,列表视图应与总宽度匹配。为此,我使用以下 xml。
<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/splashContent"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:background="#7A0225"
android:orientation="vertical" >
<TableRow
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="top|left"
android:layout_weight="0"
android:background="@drawable/search_bg_row1">
<TextView
android:id="@+id/pcomparetitle"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:paddingBottom="4dp"
android:paddingLeft="10dip"
android:paddingRight="0dip"
android:paddingTop="10dp"
android:text="Price Comparison for ISBN: "
android:textColor="#FFFFFF"
android:background="#00FF00"
android:textSize="15sp"
android:textStyle="bold" >
</TextView>
</TableRow>
<TableRow
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:gravity="center_vertical|left"
android:background="@drawable/search_bg_row3">
<ListView
android:id="@+id/pricelist"
android:background="#FF0000"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
</ListView>
</TableRow>
</TableLayout>
现在,列表视图的宽度与标题相同。由于标题与更高分辨率显示的宽度相比较短,因此列表视图占用部分宽度。如何解决这个问题呢?
I have to make a layout where in the first row I have a heading and below it, there is listview. The heading should be placed left align and the listview should be match the total width. For this, I am using the following xml.
<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/splashContent"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:background="#7A0225"
android:orientation="vertical" >
<TableRow
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="top|left"
android:layout_weight="0"
android:background="@drawable/search_bg_row1">
<TextView
android:id="@+id/pcomparetitle"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:paddingBottom="4dp"
android:paddingLeft="10dip"
android:paddingRight="0dip"
android:paddingTop="10dp"
android:text="Price Comparison for ISBN: "
android:textColor="#FFFFFF"
android:background="#00FF00"
android:textSize="15sp"
android:textStyle="bold" >
</TextView>
</TableRow>
<TableRow
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:gravity="center_vertical|left"
android:background="@drawable/search_bg_row3">
<ListView
android:id="@+id/pricelist"
android:background="#FF0000"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
</ListView>
</TableRow>
</TableLayout>
Now, the Listview is taking the width the same of the heading. As the heading is short in comparison with the width of higher resolution display, the listview is taking partial width. How to solve this problem?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为这足以让你在其下面显示一个
textview
和一个list view
:I think this is enough for u to display a
textview
and alist view
below it: