title: Android: centering buttons with percent width
body: <p>I have in my Android app a fairly simple Activity that displays three buttons, each launching a different Activity. Currently, I use a RelativeLayout to center the middle button both horizontally and vertically, then place the top and bottom buttons 30dp off the middle one (and also horizontally centered).</p>
  
  <p>What I'd like to do, however, is make the buttons stretch to be a certain percentage of the screen width. I can't figure out how to do this and keep the buttons centered. Is there a good object I can use as a "filler" in a LinearLayout on either side of the buttons (so I could just set the weights)? Or is there a way to do this that doesn't involve a LinearLayout?</p>
  
  <p>The XML for the layout as it stands is:</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" &gt;
  
      &lt;Button
          android:id="@+id/button1"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_above="@+id/button2"
          android:layout_centerHorizontal="true"
          android:layout_marginBottom="30dp"
          android:onClick="button1Callback"
          android:text="@string/button1Label" /&gt;
  
      &lt;Button
          android:id="@+id/button2"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_centerHorizontal="true"
          android:layout_centerVertical="true"
          android:onClick="button2Callback"
          android:text="@string/button2Label" /&gt;
  
      &lt;Button
          android:id="@+id/button3"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_below="@+id/button2"
          android:layout_centerHorizontal="true"
          android:layout_marginTop="30dp"
          android:text="@string/button3Label" /&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>