0

我有一个表格布局...

  <?xml version="1.0" encoding="utf-8"?>
    <TableLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/tableLayout1"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:shrinkColumns="*">



        <TableRow 
            android:id="@+id/tableRow1"
            android:layout_height="wrap_content"
            android:layout_width="match_parent"
            >
            <ImageView
                android:id="@+id/botImg01"
                android:clickable="true"  
                android:onClick="imageClick"/>
            <ImageView
                android:id="@+id/botImg02"
                android:clickable="true"  
                android:onClick="imageClick"/>
            <ImageView
                android:id="@+id/botImg03"
                android:clickable="true"  
                android:onClick="imageClick"/>   
            <ImageView
                android:id="@+id/botImg04"
                android:clickable="true"  
                android:onClick="imageClick"/>   
            <ImageView
                android:id="@+id/botImg05"
                android:clickable="true"  
                android:onClick="imageClick"/>  
            <ImageView
                android:id="@+id/botImg06"
                android:clickable="true"  
                android:onClick="imageClick"/>  
            <ImageView
                android:id="@+id/botImg07"
                android:clickable="true"  
                android:onClick="imageClick"/>  
        </TableRow>

        <TableRow
            android:id="@+id/tableRow2"
            android:layout_height="wrap_content"
            android:layout_width="match_parent"
            android:gravity="center">
            <ImageView
                android:id="@+id/botImg08"
                android:clickable="true"  
                android:onClick="imageClick"/>
            <ImageView
                android:id="@+id/botImg09"
                android:clickable="true"  
                android:onClick="imageClick"/>
            <ImageView
                android:id="@+id/botImg10"
                android:clickable="true"  
                android:onClick="imageClick"/>   
            <ImageView
                android:id="@+id/botImg11"
                android:clickable="true"  
                android:onClick="imageClick"/>   
            <ImageView
                android:id="@+id/botImg12"
                android:clickable="true"  
                android:onClick="imageClick"/>  
            <ImageView
                android:id="@+id/botImg13"
                android:clickable="true"  
                android:onClick="imageClick"/>  
            <ImageView
                android:id="@+id/botImg14"
                android:clickable="true"  
                android:onClick="imageClick"/>  
        </TableRow>

        <TableRow
            android:id="@+id/tableRow3"
            android:layout_height="wrap_content"
            android:layout_width="match_parent"
            android:gravity="center">
            <ImageView
                android:id="@+id/botImg15"
                android:clickable="true"  
                android:onClick="imageClick"/>
            <ImageView
                android:id="@+id/botImg16"
                android:clickable="true"  
                android:onClick="imageClick"/>
            <ImageView
                android:id="@+id/botImg17"
                android:clickable="true"  
                android:onClick="imageClick"/>   
            <ImageView
                android:id="@+id/botImg18"
                android:clickable="true"  
                android:onClick="imageClick"/>   
            <ImageView
                android:id="@+id/botImg19"
                android:clickable="true"  
                android:onClick="imageClick"/>  
            <ImageView
                android:id="@+id/botImg20"
                android:clickable="true"  
                android:onClick="imageClick"/>  
            <ImageView
                android:id="@+id/botImg21"
                android:clickable="true"  
                android:onClick="imageClick"/>  
        </TableRow>

        <TableRow
            android:id="@+id/tableRow4"
            android:layout_height="wrap_content"
            android:layout_width="match_parent"
            android:gravity="center">
            <ImageView
                android:id="@+id/botImg22"
                android:clickable="true"  
                android:onClick="imageClick"/>
            <ImageView
                android:id="@+id/botImg23"
                android:clickable="true"  
                android:onClick="imageClick"/>
            <ImageView
                android:id="@+id/botImg24"
                android:clickable="true"  
                android:onClick="imageClick"/>   
            <ImageView
                android:id="@+id/botImg25"
                android:clickable="true"  
                android:onClick="imageClick"/>   
            <ImageView
                android:id="@+id/botImg26"
                android:clickable="true"  
                android:onClick="imageClick"/>  
            <ImageView
                android:id="@+id/botImg27"
                android:clickable="true"  
                android:onClick="imageClick"/>  
            <ImageView
                android:id="@+id/botImg28"
                android:clickable="true"  
                android:onClick="imageClick"/>  
        </TableRow>

        <TableRow
            android:id="@+id/tableRow5"
            android:layout_height="wrap_content"
            android:layout_width="match_parent"
            android:gravity="center">
            <ImageView
                android:id="@+id/botImg29"
                android:clickable="true"  
                android:onClick="imageClick"/>
            <ImageView
                android:id="@+id/botImg30"
                android:clickable="true"  
                android:onClick="imageClick"/>
            <ImageView
                android:id="@+id/botImg31"
                android:clickable="true"  
                android:onClick="imageClick"/>   
            <ImageView
                android:id="@+id/botImg32"
                android:clickable="true"  
                android:onClick="imageClick"/>   
            <ImageView
                android:id="@+id/botImg33"
                android:clickable="true"  
                android:onClick="imageClick"/>  
            <ImageView
                android:id="@+id/botImg34"
                android:clickable="true"  
                android:onClick="imageClick"/>  
            <ImageView
                android:id="@+id/botImg35"
                android:clickable="true"  
                android:onClick="imageClick"/>  
        </TableRow>
        <TableRow
            android:id="@+id/tableRow6"
            android:layout_height="wrap_content"
            android:layout_width="match_parent"
            android:gravity="center">
            <ImageView
                android:id="@+id/botImg36"
                android:clickable="true"  
                android:onClick="imageClick"/>
            <ImageView
                android:id="@+id/botImg37"
                android:clickable="true"  
                android:onClick="imageClick"/>
            <ImageView
                android:id="@+id/botImg38"
                android:clickable="true"  
                android:onClick="imageClick"/>   
            <ImageView
                android:id="@+id/botImg39"
                android:clickable="true"  
                android:onClick="imageClick"/>   
            <ImageView
                android:id="@+id/botImg40"
                android:clickable="true"  
                android:onClick="imageClick"/>  
            <ImageView
                android:id="@+id/botImg41"
                android:clickable="true"  
                android:onClick="imageClick"/>  
            <ImageView
                android:id="@+id/botImg42"
                android:clickable="true"  
                android:onClick="imageClick"/>  
        </TableRow>


    </TableLayout>

但是我看不到最后一个 TableRow 的图像!

在所有 6 行中应该出现这些图像视图。如果它们不适合屏幕,它们可能会被缩放。但他们没有!

有什么问题?

4

1 回答 1

0

TableRow 的子项不需要在 XML 文件中指定 layout_width 和 layout_height 属性。TableRow 始终强制这些值分别为 MATCH_PARENT 和 WRAP_CONTENT。
与其将文本视图直接添加到 TableRow,不如让 TableRow 保持水平 LinearLayout 并将第二个视图添加到该保持器。
来源:TableLayout(TableRow?)在动态添加子视图时未按预期调整子视图的大小

于 2013-04-01T09:36:12.127 回答