title: Format Button Sizes within a Relative Layout
body: <p>I am creating a feedback form, and at the end there are two buttons, "Clear" and "Send". This has to be done within a Relative Layout. </p>
  
  <p>The problem is the buttons are not wide enough, I want the buttons to match the width of what is above them.</p>
  
  <p>Here is the app before trying to change the width:</p>
  
  <p><img src="https://i.stack.imgur.com/CorZc.jpg" alt="enter image description here"></p>
  
  <p><strong>And the code:</strong></p>
  
  <pre><code>    &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:tools="http://schemas.android.com/tools"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:paddingBottom="@dimen/activity_vertical_margin"
      android:paddingLeft="@dimen/activity_horizontal_margin"
      android:paddingRight="@dimen/activity_horizontal_margin"
      android:paddingTop="@dimen/activity_vertical_margin"
      tools:context=".MainActivity" &gt;
  
      &lt;EditText
          android:id="@+id/editText1"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:hint="@string/feedback_name_hint" &gt;
      &lt;/EditText&gt;
  
      &lt;EditText
          android:id="@+id/editText2"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:layout_below="@+id/editText1"
          android:hint="@string/feedback_email_hint" &gt;
      &lt;/EditText&gt;
  
      &lt;EditText
          android:id="@+id/editText3"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_above="@+id/ratingBar1"
          android:layout_alignLeft="@+id/editText2"
          android:layout_alignRight="@+id/editText2"
          android:layout_below="@+id/editText2"
          android:gravity="center_vertical|top"
          android:hint="@string/feedback_actual"
          android:inputType="textMultiLine" &gt;
  
      &lt;/EditText&gt;
  
      &lt;RatingBar
          android:id="@+id/ratingBar1"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_above="@+id/Button01"
          android:layout_alignLeft="@+id/editText3"
          android:layout_marginBottom="21dp" /&gt;
  
    &lt;Button
          android:id="@+id/button1"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_alignLeft="@+id/ratingBar1"
          android:layout_alignParentBottom="true"
          android:layout_marginBottom="18dp"
          android:text="@string/Clear" /&gt;
  
      &lt;Button
          android:id="@+id/Button01"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_alignBaseline="@+id/button1"
          android:layout_alignBottom="@+id/button1"
          android:layout_toRightOf="@+id/button1"
          android:text="@string/Send" /&gt; 
  
  
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p><strong>I have tried to create a linear layout around the buttons, like this:</strong> </p>
  
  <pre><code>    &lt;LinearLayout 
      android:layout_width="fill_parent"
      android:layout_height="fill_parent"
      android:gravity="top"
      android:orientation="horizontal" &gt;
  
      &lt;Button 
          android:id="@+id/button3"
          android:layout_width="0dp"
           android:layout_height="wrap_content"
           android:layout_weight="1"
           android:text="@string/Clear"
      /&gt;
      &lt;Button
          android:id="@+id/button4"
          android:layout_width="0dp"
           android:layout_height="wrap_content"
           android:layout_weight="1"
           android:text="@string/Send"
      /&gt;
   &lt;/LinearLayout&gt;
  </code></pre>
  
  <p><strong>However, whilst the buttons are the size that I want, they jump to the top of the view, and affect the other elements:</strong></p>
  
  <p><img src="https://i.stack.imgur.com/uCr1I.jpg" alt="enter image description here"></p>
  
  <p>Any help on this would be greatly appreciated, thanks. </p>
  
  <p><strong>SOLVED:</strong></p>
  
  <p>It worked by surrouding buttons with the following linear layout: (note how Rating Bar is set to be above the <code>linearlayoutid</code>)</p>
  
  <pre><code>    &lt;RatingBar
          android:id="@+id/ratingBar1"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_above="@+id/linearlayout_id"
          android:layout_alignLeft="@+id/editText3"
          android:layout_marginBottom="21dp" /&gt;
  
   &lt;LinearLayout 
       android:id="@+id/linearlayout_id"
          android:layout_width="fill_parent"
          android:layout_height="wrap_content"
          android:layout_alignParentBottom="true"
          android:layout_alignParentLeft="true"
          android:gravity="center_horizontal"
          android:layout_marginBottom="18dp"
          android:orientation="horizontal" &gt;
  
          &lt;Button
              android:id="@+id/button1"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_weight="1"
              android:text="@string/Clear" /&gt;
  
          &lt;Button
              android:id="@+id/Button01"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_weight="1"
              android:text="@string/Send" /&gt;
   &lt;/LinearLayout&gt;
  </code></pre>