0
我試圖在Android中製作這樣的表格佈局。在Android中設置表格佈局
第一列 - 2個按鈕,下一列第二行一個按鈕。按鈕的大小應該相同。我使用0寬度和重量1並拉伸列。
在XML:
<TableLayout
android:id="@+id/tableLayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:stretchColumns="*" >
<TableRow>
<Button
android:id="@+id/button_stereo_system_state"
style="@style/StyleButton"
android:background="@drawable/background_button_off"
android:drawableTop="@drawable/icon_button_on_off"
android:text="@string/button_text_option_off" />
<Button
android:id="@+id/button_stereo_system_radio"
style="@style/StyleButton"
android:background="@drawable/background_button_off"
android:drawableTop="@drawable/icon_button_play"
android:text="@string/button_text_play_radio" />
</TableRow>
<TableRow>
<Button
android:id="@+id/button_stereo_system_cd"
style="@style/StyleButton"
android:layout_column="0"
android:background="@drawable/background_button_off"
android:drawableTop="@drawable/icon_button_play"
android:text="@string/button_text_play_cd" />
</TableRow>
</TableLayout>
在樣式:
<style name="StyleButton">
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_width">0dip</item>
<item name="android:layout_weight">1</item>
<item name="android:layout_margin">10dip</item>
<item name="android:textSize">19sp</item>
<item name="android:textColor">@color/color_text_button</item>
</style>
隨着第二行按鈕此源代碼被拉伸並佔用了整個行。如何做到這一點?
也許增加無形的按鈕? – Pawel