【问题标题】:Android table layout width probAndroid表格布局宽度概率
【发布时间】:2012-01-24 10:44:00
【问题描述】:

我必须做一个布局,在第一行我有一个标题,在它下面,有列表视图。标题应左对齐,列表视图应与总宽度匹配。为此,我使用以下 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>

现在,Listview 的宽度与标题相同。由于标题与更高分辨率显示的宽度相比较短,因此列表视图采用部分宽度。如何解决这个问题?

【问题讨论】:

标签: android android-layout width tablelayout tablerow


【解决方案1】:

我认为这足以让您在其下方显示textviewlist view

 <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/splashContent"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="#7A0225"
    android:orientation="vertical" >

        <TextView
            android:id="@+id/pcomparetitle"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Price Comparison for ISBN: "
            android:textColor="#FFFFFF"
            android:background="#00FF00"
            android:textSize="15sp"
            android:textStyle="bold" >
        </TextView>

        <ListView
            android:id="@+id/pricelist"
            android:background="#FF0000"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent">
        </ListView>
    </LinearLayout>

【讨论】:

    猜你喜欢
    • 2011-05-02
    • 1970-01-01
    • 2014-06-02
    • 2013-10-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多