Reputation: 763
Is there a better way to do this, where buttons are bottom aligned on either side of the screen? Important parts are alignParentBottom, which appears to only be available in RelativeLayout, and layout_gravity, which appears to only be available in LinearLayout and its subclasses like TableLayout, of which RelativeLayout is not one.
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true">
<TableLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:stretchColumns="1">
<TableRow>
<Button
android:id="@+id/list_delete"
android:text="@string/list_delete"
android:visibility="invisible"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
<Button
android:id="@+id/list_save"
android:text="@string/list_add"
android:layout_gravity="right"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
</TableRow>
</TableLayout>
</RelativeLayout>
Android lint is giving me errors like this:
Upvotes: 2
Views: 573
Reputation: 1849
Try this
<RelativeLayout//this will be your parent layout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
<Button
android:id="@+id/list_delete"
android:text="@string/list_delete"
android:visibility="invisible"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
<Button
android:id="@+id/list_save"
android:text="@string/list_add"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
</RelativeLayout>
Upvotes: 4