Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid - Two buttons in same line filling the whole width
    primarykey
    data
    text
    <p>I have a little problem defining a Relative Layout. I have a List View with scroll and two buttons always visible at the bottom of the list view. I just would like my two button have 50% of the width, filling the line. This is my code:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" &gt; &lt;Button android:id="@+id/testbutton" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:text="Save" /&gt; &lt;Button android:id="@+id/cancelButton" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:layout_toRightOf="@+id/testbutton" android:text="Cancel"/&gt; &lt;ListView android:layout_width="fill_parent" android:layout_height="fill_parent" android:id="@+id/LstPeriodOptions" android:layout_alignParentTop="true" android:layout_above="@id/testbutton" /&gt; &lt;/RelativeLayout&gt; </code></pre> <p>I tried to introduce the buttons in a Linear Layout and give the gravity=1 with width=0dp but in that case the ListView dissapears. Could you help me please?</p> <p>Sorry for my english. This is the result I would like to have: </p> <p><img src="https://i.imgur.com/FiWXhzp.jpg" alt="Result"></p> <p>Thanks a lot, best regards.</p> <p>EDIT: This is what I tried with Linear Layout:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" &gt; &lt;LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/container" &gt; &lt;Button android:id="@+id/testbutton" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:text="Guardar" /&gt; &lt;Button android:id="@+id/cancelButton" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:layout_toRightOf="@+id/testbutton" android:text="Cancelar"/&gt; &lt;/LinearLayout&gt; &lt;ListView android:layout_width="fill_parent" android:layout_height="fill_parent" android:id="@+id/LstPeriodOptions" android:layout_alignParentTop="true" android:layout_above="@id/container" /&gt; &lt;/RelativeLayout&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload