【问题标题】:android table layout one for both (landscape and portrait view)android 表格布局之一(横向和纵向视图)
【发布时间】:2011-01-12 13:43:28
【问题描述】:

我想创建以下布局,它应该 100% 以横向形式显示为纵向形式。

alt text http://www.freeimagehosting.net/uploads/b12bb68569.png

这是我尝试过但不起作用的代码

<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content" android:stretchColumns="0">

<TableRow>
    <TableLayout android:layout_width="wrap_content"
        android:layout_height="wrap_content">
        <TableRow>
            <TableLayout android:layout_width="wrap_content"
                android:layout_height="wrap_content" android:orientation="horizontal">
                <TableRow>
                    <TextView android:id="@+id/reviewItemEntityName"
                        android:layout_height="wrap_content" android:text="12345"
                        android:textColor="@color/maroon" />

                    <ImageView android:id="@+id/reviewItemStarRating"
                        android:layout_width="wrap_content" android:layout_height="wrap_content"
                        android:src="@drawable/title_1_star" />
                </TableRow>
            </TableLayout>



        </TableRow>

        <TableRow>

            <TextView android:id="@+id/reviewItemDescription"
                android:layout_width="0dip" android:layout_height="wrap_content"
                android:text="Description comes here" android:textSize="12sp" />
        </TableRow>

    </TableLayout>
    <ImageView android:layout_width="wrap_content"
        android:layout_height="wrap_content" android:src="@drawable/arrow_nxt"
        android:layout_gravity="center_vertical"
        android:layout_alignParentRight="true" />
    </TableRow>
</TableLayout>

【问题讨论】:

    标签: android tablelayout


    【解决方案1】:

    我认为这就是您要寻找的东西,记得使用“android:layout_weight”值,它基本上会告诉小部件它们应该扩展多少(使用可用的可用空间)。

    玩得开心。

    <TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent" 
        >
    
    <TableRow android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_weight="1">
        <TableLayout android:layout_width="fill_parent"
            android:layout_height="fill_parent" 
            android:layout_weight="1">      
            <TableRow>
                <TextView android:text="TextView Up Left" 
                    android:id="@+id/TextView01" 
                    android:layout_width="wrap_content" 
                    android:layout_height="wrap_content"
                    android:gravity="left"
                    android:layout_weight="1">
                </TextView>
                <ImageView android:id="@+id/ImageView01" 
                    android:layout_width="wrap_content" 
                    android:layout_height="wrap_content"
                    android:src="@android:drawable/btn_plus"
                    android:gravity="right">
                </ImageView>
            </TableRow>
            <TableRow>
            <TextView android:text="Text view with padding" 
                android:id="@+id/TextView02" 
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" 
                android:paddingBottom="20.0dp" 
                android:paddingLeft="20.0dp" 
                android:paddingRight="20.0dp" 
                android:paddingTop="20.0dp"
                android:layout_weight="1">
            </TextView>
            </TableRow>
        </TableLayout>
        <TableLayout android:id="@+id/TableLayout01" 
            android:layout_width="fill_parent" 
            android:layout_height="fill_parent"
            android:layout_weight="0">
            <TableRow android:layout_width="fill_parent" 
                android:layout_height="fill_parent"
                android:layout_weight="1">
            <ImageView android:id="@+id/ImageView02" 
                android:layout_width="wrap_content" 
                android:layout_height="wrap_content"
                android:src="@android:drawable/btn_minus"
                android:layout_gravity="center"
                >
            </ImageView>
            </TableRow>
        </TableLayout>
    </TableRow>
    </TableLayout>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-11-21
      相关资源
      最近更新 更多