Pen*_*m10 19 xml android views tablelayout
我有一个表,每行有2行,有3个按钮.如何使按钮平均填充空间.在HTML中我会给它们33%的宽度.
另外你知道我可以创建一个连续4个图像按钮作为网格布局的视图,类似于启动器.
Tim*_*mmm 16
我终于在这里找到了真正的答案:http://androidadvice.blogspot.com/2010/10/tablelayout-columns-equal-width.html
这里还有一个关于stackoverflow的最小例子:https://stackoverflow.com/a/2865558/265521
例:
<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="match_parent"
android:layout_width="match_parent">
<TableRow>
<Button
android:layout_width="0dip"
android:layout_height="match_parent"
android:text="Why is doing layouts on Android"
android:layout_weight="1"
/>
<Button
android:layout_width="0dip"
android:layout_height="match_parent"
android:text="so"
android:layout_weight="1"
/>
</TableRow>
<TableRow>
<Button
android:layout_width="0dip"
android:layout_height="match_parent"
android:text="damn"
android:layout_weight="1"
/>
<Button
android:layout_width="0dip"
android:layout_height="match_parent"
android:text="frustrating?"
android:layout_weight="1"
/>
</TableRow>
</TableLayout>
Run Code Online (Sandbox Code Playgroud)