I'm trying to create a phone dialer view, using a TableLayout to create the 12 buttons in a 3x4 grid. I would like the rows to stretch vertically to use up all available space equally, but it appears fill_parent doesn't work on TableRows.
I would like not to have to use setMinimumHeight - is there a way to do this properly in the layout?
Thanks very much,
Ed
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" > <TableLayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:stretchColumns="*" > <TableRow android:layout_weight="1" android:gravity="center"> <Button android:text="Button" android:layout_width="fill_parent" android:layout_height="fill_parent"/> <Button android:text="Button" android:layout_width="fill_parent" android:layout_height="fill_parent"/> <Button android:text="Button" android:layout_width="fill_parent" android:layout_height="fill_parent"/> </TableRow> <TableRow android:layout_weight="1" android:gravity="center"> <Button android:text="Button" android:layout_width="fill_parent" android:layout_height="fill_parent"/> <Button android:text="Button" android:layout_width="fill_parent" android:layout_height="fill_parent"/> <Button android:text="Button" android:layout_width="fill_parent" android:layout_height="fill_parent"/> </TableRow> <TableRow android:layout_weight="1" android:gravity="center"> <Button android:text="Button" android:layout_width="fill_parent" android:layout_height="fill_parent"/> <Button android:text="Button" android:layout_width="fill_parent" android:layout_height="fill_parent"/> <Button android:text="Button" android:layout_width="fill_parent" android:layout_height="fill_parent"/> </TableRow> <TableRow android:layout_weight="1" android:gravity="center"> <Button android:text="Button" android:layout_width="fill_parent" android:layout_height="fill_parent"/> <Button android:text="Button" android:layout_width="fill_parent" android:layout_height="fill_parent"/> <Button android:text="Button" android:layout_width="fill_parent" android:layout_height="fill_parent"/> </TableRow> </TableLayout> </LinearLayout>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With