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