By Alvin Alexander. Last updated: January 24, 2017
As a quick note, if you need to get an Android TableRow
to align right, I can confirm that this layout code works:
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:stretchColumns="1"> <TableRow android:layout_width="fill_parent"> <Spinner android:id="@+id/spinner1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:entries="@array/playerRatingArray" android:layout_column="1" android:layout_gravity="right" android:padding="10dip" /> <Spinner android:id="@+id/spinner2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:entries="@array/playerRatingArray" android:layout_column="2" android:layout_gravity="right" android:padding="10dip" /> <Spinner android:id="@+id/spinner3" android:layout_width="wrap_content" android:layout_height="wrap_content" android:entries="@array/playerRatingArray" android:layout_column="3" android:layout_gravity="right" android:padding="10dip" /> </TableRow> </TableLayout>
The keys were defining the TableRow
like this:
<TableRow android:layout_width="fill_parent">
and then setting android:layout_gravity="right"
for each of the elements in the TableRow
.