我試圖用4個單元格創建一個表格,每行有2個ImageButton
。 出於某種原因,ImageButton
似乎是寬和退出屏幕,即使tablerow
寬度爲match parent
在表中擬合ImageButton
下面的代碼:
<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>
任何想法我如何使它完全適合屏幕?
謝謝! :)
而是這個'的android:SRC = 「@繪製/月食」'使用'的android:背景= 「@繪製/月食」',並嘗試一次 – Zombie