title: Android Layout Weight
body: <p>I am new to Android development and I have a question about setting weight in a linear layout.  </p>
  
  <p>I am trying to create a row with two custom buttons and a custom edit text.  The edit text should only take up as much room as its content, and the two buttons should expand horizontally to fill the rest of the available space in the row. Like this...</p>
  
  <pre><code>| [#Button++#] [#Button--#] [et] |
  </code></pre>
  
  <p>After several attempts this is the closest I can get to what I want, even though it seems overly complicated.</p>
  
  <pre><code>| [Button] [Button] [###ET###] |
  </code></pre>
  
  <hr>
  
  <pre><code>&lt;LinearLayout 
      android:orientation="horizontal"
      android:layout_width="fill_parent"
      android:layout_height="wrap_content"
      android:gravity="center_horizontal|center_vertical"
      android:layout_weight="1"
      &gt;
  
      &lt;LinearLayout 
          android:orientation="horizontal"
          android:layout_width="fill_parent"
          android:layout_height="wrap_content"
          android:layout_weight="1"
          android:gravity="center_horizontal|center_vertical"
          &gt;
          &lt;RelativeLayout 
              android:id="@+id/btn_plus_container" 
              android:layout_width="fill_parent" 
              android:layout_height="wrap_content"
              &gt;
              &lt;ImageButton 
                  android:layout_height="wrap_content"
                  android:layout_width="fill_parent" 
                  android:id="@+id/btn_plus" 
                  android:background="@drawable/btn"
                  android:layout_centerInParent="true"
                  &gt;&lt;/ImageButton&gt;
              &lt;TextView 
                  android:textColor="#FAFAF4"
                  android:id="@+id/tv_dice_plus" 
                  android:text="@string/tv_plus" 
                  android:layout_width="wrap_content" 
                  android:layout_height="wrap_content"
                  android:layout_centerInParent="true"
                  &gt;&lt;/TextView&gt;
          &lt;/RelativeLayout&gt;
      &lt;/LinearLayout&gt;
      &lt;LinearLayout 
          android:orientation="horizontal"
          android:layout_width="fill_parent"
          android:layout_height="wrap_content"
          android:layout_weight="1"
          android:gravity="center_horizontal|center_vertical"
          &gt;
          &lt;RelativeLayout 
              android:id="@+id/btn_minus_container" 
              android:layout_width="fill_parent" 
              android:layout_height="wrap_content"
              &gt;
              &lt;ImageButton 
                  android:layout_height="wrap_content"
                  android:layout_width="fill_parent" 
                  android:id="@+id/btn_minus" 
                  android:background="@drawable/btn"
                  android:layout_centerInParent="true"
                  &gt;&lt;/ImageButton&gt;
              &lt;TextView 
                  android:textColor="#FAFAF4"
                  android:id="@+id/btn_minus" 
                  android:text="@string/tv_minus" 
                  android:layout_width="wrap_content" 
                  android:layout_height="wrap_content"
                  android:layout_centerInParent="true"
                  &gt;&lt;/TextView&gt;
          &lt;/RelativeLayout&gt;
      &lt;/LinearLayout&gt;
      &lt;LinearLayout 
          android:orientation="horizontal"
          android:layout_width="fill_parent"
          android:layout_height="wrap_content"
          android:layout_weight="1"
          android:gravity="center_horizontal|center_vertical"
          &gt;
          &lt;EditText 
              android:textColor="#FAFAF4"
              android:text="@string/et_output" 
              android:id="@+id/et_output" 
              android:layout_width="wrap_content" 
              android:layout_height="wrap_content"
              android:inputType="number"
              android:selectAllOnFocus="true" 
              android:minWidth="50sp"         
              android:maxWidth="50sp"
              android:background="@drawable/tv_black_background3"
              android:textColorHighlight="#c30505"
              &gt;&lt;/EditText&gt;
      &lt;/LinearLayout&gt;
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>As I understand setting [android:layout_weight="2"] for the linear layouts holding the buttons should make them take up more room than the edit text, but it does the opposite for me, making them both half the size.</p>
  
  <pre><code>| [Btn] [Btn] [#####et#####] |
  </code></pre>
  
  <p>I have tried so many different combinations I can't even remember them, and none have worked.</p>