title: How to change layout to use minimum height in android programming?
body: <p>In android programming, how do you change the layout height to be the smallest it can be such that all the elements still show up on it.</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:orientation="vertical" &gt;
  
      &lt;TextView
          android:id="@+id/textview_username"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:text="@+string/email" /&gt;
  
      &lt;EditText
          android:id="@+id/textinput_username"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:ems="10"
          android:inputType="textEmailAddress" /&gt;
  
      &lt;TextView
          android:id="@+id/textview_password"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:text="@+string/password" /&gt;
  
      &lt;EditText
          android:id="@+id/textinput_password"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:ems="10"
          android:inputType="textPassword" /&gt;
  
      &lt;LinearLayout
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:orientation="horizontal" &gt;
          &lt;Button
              android:id="@+id/button_exit"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:text="@+string/cancel" /&gt;
  
          &lt;Button
              android:id="@+id/button_login"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:text="@+string/ok" /&gt;
      &lt;/LinearLayout&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>This is my code, and when I run this, there is a lot of white space showing. This layout only shows in dialog boxes.</p>
  
  <p>Thanks.</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>I got the height to be minimized, but the OK button is now appearing right beside the cancel button. I want it to be right aligned.</p>