Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android TableRow stretch vertically to fill screen

Tags:

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

like image 533
Ed Jellard Avatar asked Apr 04 '11 12:04

Ed Jellard


1 Answers

<?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> 

enter image description here

like image 172
GrAnd Avatar answered Sep 22 '22 19:09

GrAnd