我有TableLayout,我想將按鈕作爲單元格。所有按鈕應具有相同的寬度。所有的按鈕應該有相同的高度。 (因爲我想填滿屏幕,重量和高度會有所不同)。Android TableLayout - 等寬和等高的單元格 - 不起作用,爲什麼
我確定我正在做的一切正確,但不幸的是只有寬度是相同的。問題在於高度 - 前兩行高度相同,第三行更小(或者更確切地說,只要按鈕不包含任何文本,高度相同,但是當我放置文本時,高度不相等)。我無法相信它不起作用,所以我甚至製作了屏幕快照,並在圖形程序中檢查了距離。
我的表:
<TableLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="1"
android:stretchColumns="*"
android:shrinkColumns="*"
android:weightSum="3"
android:padding="@dimen/dialog_margin"
>
<TableRow
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="1"
android:stretchColumns="*"
android:gravity="center"
android:weightSum="2">
<Button
android:id="@+id/button_0"
android:layout_width="0dip"
android:layout_height="match_parent"
android:layout_weight="1"
/>
<Button
android:id="@+id/button_1"
android:layout_width="0dip"
android:layout_height="match_parent"
android:layout_weight="1"
/>
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="1"
android:stretchColumns="*"
android:gravity="center"
android:weightSum="2">
// buttons analogously as in previous row....
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="1"
android:stretchColumns="*"
android:gravity="center"
android:weightSum="2">
// buttons analogously as in previous row....
</TableRow>
我想也設置TableRow
高度match_parent
。它沒有幫助。
和btw如何shrinkColums
工作,特別是與stretchColumns
一起? (我的版本有和沒有shrinkColumns
,看起來沒有什麼區別
請告訴我,如果它會工作,我也很好奇。 –
O.對不起。它應該是。斜槓很重要 –
http://docs.oracle.com/javase/tutorial/uiswing/components/html.htmlhttp://docs.oracle.com/javase/tutorial/uiswing/components/html.html –