0

我正在尝试创建一个包含 4 个单元格的表格,每行有 2 个ImageButton。出于某种原因,ImageButton即使tablerow宽度为match parent

这是代码:

<LinearLayout 
    android:layout_height="wrap_content"
     android:layout_width="match_parent"
    android:layout_weight="1" >
<TableLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"    

   >

    <TableRow
        android:id="@+id/tableRow1"
        android:layout_width="match_parent"
        android:layout_height="match_parent" >

        <ImageButton
            android:id="@+id/button5"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_alignParentRight="true"
            android:layout_below="@+id/button4"
            android:background="@null"
            android:onClick="changepic2"

            android:src="@drawable/breakingdawn"
            android:text="Breaking Dawn" />

        <ImageButton
            android:id="@+id/button4"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_alignBaseline="@+id/button1"
            android:layout_alignBottom="@+id/button1"
            android:layout_alignLeft="@+id/button5"
            android:layout_alignParentRight="true"
            android:background="@null"
            android:onClick="changepic3"

            android:src="@drawable/newmoon" />

    </TableRow>

    <TableRow
        android:id="@+id/tableRow3"
        android:layout_width="match_parent"
        android:layout_height="match_parent" >

        <ImageButton
            android:id="@+id/button1"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_above="@+id/button3"
            android:layout_alignParentLeft="true"
            android:onClick="changepic"

            android:paddingTop="2dp"

            android:src="@drawable/twilight"
            android:background="@null"/>

        <ImageButton
            android:id="@+id/button3"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_alignParentBottom="true"
            android:onClick="changepic1"

            android:src="@drawable/eclipse"
            android:paddingTop="2dp"
            android:background="@null" />
    </TableRow>
</TableLayout>

知道如何让它完全适合屏幕吗?

谢谢!!:)

4

1 回答 1

0

代替

这个 android:src="@drawable/eclipse"

利用 android:background="@drawable/eclipse"

并尝试一次。它可能会帮助你

并使用wrapcontent而不是matchparent

于 2012-11-05T10:43:58.133 回答