title: Android Layout: width half of parent
body: <p>I have a very simple layout that I can't make it looks like I want. It's a LinearLayout with a button and a Switch. I want them to show one above the other, but I want their width to be the half of the parent layout.</p>
  
  <pre><code>|--LinearLayout---------|
  |                       |
  | -----------           |
  ||   Switch  |          |
  | -----------           |
  | -----------           |
  ||   button  |          |
  | -----------           |
   ------------------------
  </code></pre>
  
  <p>I've been looking at other similar answer in SO but I couldn't find a solution that works for me. This is what I've tried so far:</p>
  
  <pre><code>            &lt;LinearLayout
                  android:layout_width="match_parent"
                  android:layout_height="wrap_content"
                  android:orientation="vertical"
                  android:weightSum="2" &gt;
  
                  &lt;Switch
                      android:id="@+id/remember_me_switch"
                      android:layout_width="match_parent"
                      android:layout_height="wrap_content"
                      android:layout_weight="1"
                      android:hint="@string/remember" /&gt;
  
                  &lt;Button
                      android:id="@+id/share_button"
                      android:layout_width="match_parent"
                      android:layout_height="match_parent"
                      android:layout_weight="1"
                      android:onClick="loginOnclick"
                      android:text="@string/login_button_text" /&gt;
  
              &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>With this, the button and the switch take all the space of the parent instead of take only the half.
  I've tried with <code>android:layout_width = 0dp</code> in the children but it makes they disappear.</p>
  
  <p>Any help, please?</p>