代表這我需要代表下列圖:
如何Android中佈局
每個X將是圖像按鈕。我正在考慮製作三個表格,每列一列,每個單元格高度爲表格高度的一半。問題在於桌子需要伸展或縮小,因爲我擔心屏幕上會顯示所有內容,而桌子是唯一可以改變尺寸的部分,並且整個桌面仍然可以正常工作。我遇到的問題是行只與圖像按鈕一樣大。雖然所有的圖像按鈕都是相同的大小,特別是左右兩個表格,但需要在圖像按鈕周圍填充一些填充以使其更加完整。我會爲按鈕添加邊距,但是這會挫敗我正在改造的問題......我想。有什麼建議麼?
代表這我需要代表下列圖:
如何Android中佈局
每個X將是圖像按鈕。我正在考慮製作三個表格,每列一列,每個單元格高度爲表格高度的一半。問題在於桌子需要伸展或縮小,因爲我擔心屏幕上會顯示所有內容,而桌子是唯一可以改變尺寸的部分,並且整個桌面仍然可以正常工作。我遇到的問題是行只與圖像按鈕一樣大。雖然所有的圖像按鈕都是相同的大小,特別是左右兩個表格,但需要在圖像按鈕周圍填充一些填充以使其更加完整。我會爲按鈕添加邊距,但是這會挫敗我正在改造的問題......我想。有什麼建議麼?
有可能是一個更好的辦法,但下面是要做到這一點的方法之一。按鈕是否需要拉伸以適應細胞?或者他們只會集中在?假如是後者,這裏有一個建議(我不是這個信心,但我相信它應該工作):
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal"
>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:layout_weight="1"
android:gravity="center"
>
<ImageButton
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:src="@drawable/drawable11"
/>
<ImageButton
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:src="@drawable/drawable12"
/>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:layout_weight="1"
android:gravity="center"
>
<ImageButton
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:src="@drawable/drawable21"
/>
<ImageButton
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:src="@drawable/drawable22"
/>
<ImageButton
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:src="@drawable/drawable23"
/>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:layout_weight="1"
android:gravity="center"
>
<ImageButton
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:src="@drawable/drawable11"
/>
<ImageButton
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:src="@drawable/drawable12"
/>
</LinearLayout>
</LinearLayout>
我遺憾的是還沒有安裝Eclipse,現在來測試這一點,但是這應該是接近到什麼你需要。使用RelativeLayout可能會有一個更清晰的方式(使用更少的嵌套視圖),但這不在我頭頂,給你一些開始。
嘗試使用網格視圖。
這實際上看起來像一個不錯的主意。我會試試看,然後和你一起回去。謝謝 – FuegoFingers 2010-11-05 19:50:51
我不得不使用RelativeLayout作爲保持圖像按鈕而不是線性佈局的子項,並且還在圖像按鈕上設置了align_vertical = true,但是這有效。謝謝 – FuegoFingers 2010-11-05 20:16:33
太棒了,感謝您的後續修復,很高興爲您解決了問題! – kcoppock 2010-11-05 20:24:44