<tablelayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:stretchColumns="1">
<TableRow>
<!-- Column 1 -->
<TextView
android:id="@+id/tbl_txt1"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:background="@color/red"
android:textColor="@color/white"
android:padding="10dip"
android:layout_margin="4dip"
android:layout_weight="1"
android:text="Column 1" />
<!-- Column 2 -->
<TextView
android:id="@+id/tbl_txt2"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:background="@color/red"
android:textColor="@color/white"
android:padding="10dip"
android:layout_margin="4dip"
android:layout_weight="1"
android:text="Column 2" />
<!-- Column 3 -->
<TextView
android:id="@+id/tbl_txt3"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:background="@color/red"
android:textColor="@color/white"
android:padding="10dip"
android:layout_margin="4dip"
android:layout_weight="1"
android:text="Column 3" />
</TableRow>
</TableLayout>
Showing posts with label layout. Show all posts
Showing posts with label layout. Show all posts
Tuesday, October 12, 2010
TableLayout columns equal width
Something easy like columns of equal width in a TableLayout shouldn't be difficult. It's not, but there is a trick to getting the desired layout. layout_width="0dip" and layout_weight="1" tags must be set in your XML layout. Here's an example:
Friday, October 1, 2010
Position two buttons on each side of the screen
Working with layouts in Android can sometimes be extremely simple and other times extremely difficult to accomplish seemingly simple tasks. I fought for a while with how to position two buttons on each side of the screen with a space between them. I'll spare all of my trials and tribulations, and get right to the code that makes it work...
Subscribe to:
Posts (Atom)