Android XML:ListView元素比例

时间:2011-06-28 07:31:13

标签: android listview android-layout android-listview

我有点困惑,不知道如何解决这个样式问题。我有一个ListView元素,包含2个图像和3个TextView(以XML格式创建)。

图像应围绕TextViews,并应以每种分辨率和每个方向显示。一旦我超过TextViews的当前长度,右侧的图像就会离开显示器(用QVGA测试)。

知道如何解决我的问题吗?

<TableLayout
    android:id="@+id/tableLayout_ScrollviewEntry"
    android:layout_width="wrap_content"
    android:stretchColumns="1" android:layout_height="fill_parent">
    <View
     android:layout_width="fill_parent"
     android:layout_height="1dip"
     android:background="#cccccc" />
        <TableRow
            android:layout_height="wrap_content"
            android:id="@+id/MainRow"
            android:layout_width="wrap_content">
            <ImageView
                android:src="@drawable/favs_action"
                android:layout_height="wrap_content"
                android:layout_width="match_parent"
                android:id="@+id/image1">
            </ImageView>

            <TableLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" android:id="@+id/InnerTextTable">

                <TableRow
                    android:id="@+id/InnerRow0"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content">
                    <TextView
                    android:textColor="#4444dd"
                        android:scrollHorizontally="false"
                        android:layout_height="wrap_content"
                        android:textAppearance="?android:attr/textAppearanceLarge"
                        android:id="@+id/textView1" 
                        android:editable="false"
                         android:layout_width="match_parent" 
                         android:hapticFeedbackEnabled="false" 
                         android:text="xxxxxxxx Special xxxxx">
                    </TextView>
                </TableRow>

                <TableLayout
                    android:id="@+id/InnerRow1"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content">
                    <TextView
                    android:textColor="#000000"
                        android:id="@+id/textView2"
                        android:text="xxxxx xxxx xxx x xxxxxxxx"
                        android:layout_height="wrap_content"
                        android:textAppearance="?android:attr/textAppearanceMedium"
                        android:layout_width="wrap_content"></TextView>

                </TableLayout>
                <TableRow
                    android:id="@+id/InnerRow2"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content">

                    <TextView
                    android:textColor="#888888"
                        android:text="xxxxx xxxxxxxxxx"
                        android:layout_height="wrap_content"
                        android:textAppearance="?android:attr/textAppearanceSmall"
                        android:id="@+id/textView3"
                        android:layout_width="wrap_content"></TextView>
                </TableRow>
            </TableLayout>
            <ImageView
                android:src="@drawable/image2"
                android:layout_height="wrap_content"
                android:layout_width="wrap_content"
                android:id="@+id/image1" android:layout_gravity="left">
            </ImageView>
        </TableRow>
    <View
     android:layout_width="fill_parent"
     android:layout_height="1dip"
     android:background="#cccccc" />
    </TableLayout>      
</LinearLayout>

1 个答案:

答案 0 :(得分:0)

相对布局将是您问题的最佳解决方案......您可以将图像放在任意一侧,将三个文本放在它们之间。对于较长的文本,您可以使用textView的ellipsize属性。

相关问题