Reputation: 1892
Can't understand, why buttons are not identical in their sizes. Earlier, I used LinearLayout instead of RelativeLayout as a root, but after some googling I understand, there is no chance to make footer with LL, so I make it RL and adjusted by coping previous LL with buttons to RL, but.. Look at this. I found it with ruler. It really cut my eyes
Also I can't understand, why margin in RL doesn't work anyway (I deleted in from below code), and how I can margin elements inside RL?!
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/RelativeLayout_root"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:id="@+id/linearLayout_buttons"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true" >
<Button
android:id="@+id/button_add"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/all_mentions_Add" />
<Button
android:id="@+id/button_delete"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/all_mentions_Delete" />
</LinearLayout>
<ListView
android:id="@+id/listView_mentions"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="@id/linearLayout_buttons" >
</ListView>
</RelativeLayout>
Upvotes: 0
Views: 150
Reputation: 38098
Just set
android:layout_width="0dp"
instead of
android:layout_width="wrap_content"
in your Buttons, for weights to work (trick!)
Also set android:orientation="horizontal"
in your LinearLayout
Upvotes: 1
Reputation: 24848
Try this way,hope this will help you to solve your problem.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<ListView
android:id="@+id/listView_mentions"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"/>
<LinearLayout
android:id="@+id/linearLayout_buttons"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<Button
android:id="@+id/button_add"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/all_mentions_Add" />
<Button
android:id="@+id/button_delete"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/all_mentions_Delete" />
</LinearLayout>
</LinearLayout>
Upvotes: 1
Reputation: 3497
You can make footer with LL:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/RelativeLayout_root"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ListView
android:id="@+id/listView_mentions"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1">
</ListView>
<LinearLayout
android:id="@+id/linearLayout_buttons"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<Button
android:id="@+id/button_add"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/all_mentions_Add" />
<Button
android:id="@+id/button_delete"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/all_mentions_Delete" />
</LinearLayout>
</LinearLayout>
Also change width of buttons to match_parent
if You want to make width of buttons identically.
Upvotes: 1