title: Percentage width in a RelativeLayout
body: <p>I am working on a form layout for a Login <code>Activity</code> in my Android App. The image below is how I want it to look like:</p>
  
  <p><img src="https://i.stack.imgur.com/5mrcx.png" alt="enter image description here"></p>
  
  <p>I was able to achieve this layout with the following <strong>XML</strong>. The problem is, it's a bit hackish. I had to hard-code a width for the host EditText. Specifically, I had to specify:</p>
  
  <pre><code>android:layout_width="172dp" 
  </code></pre>
  
  <p>I'd really like to give a percentage width to the host and port EditText's . (Something like 80% for the host, 20% for the port.) Is this possible? The following XML works on my Droid, but it doesn't seem to work for all screens. I would really like a more robust solution. </p>
  
  <pre><code>&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:id="@+id/main"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent" &gt;
  
      &lt;TextView
          android:id="@+id/host_label"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_below="@+id/home"
          android:paddingLeft="15dp"
          android:paddingTop="0dp"
          android:text="host"
          android:textColor="#a5d4e2"
          android:textSize="25sp"
          android:textStyle="normal" /&gt;
  
      &lt;TextView
          android:id="@+id/port_label"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_below="@+id/home"
          android:layout_toRightOf="@+id/host_input"
          android:paddingTop="0dp"
          android:text="port"
          android:textColor="#a5d4e2"
          android:textSize="25sp"
          android:textStyle="normal" /&gt;
  
      &lt;EditText
          android:id="@+id/host_input"
          android:layout_width="172dp"
          android:layout_height="wrap_content"
          android:layout_below="@id/host_label"
          android:layout_marginLeft="15dp"
          android:layout_marginRight="15dp"
          android:layout_marginTop="4dp"
          android:background="@android:drawable/editbox_background"
          android:inputType="textEmailAddress" /&gt;
  
      &lt;EditText
          android:id="@+id/port_input"
          android:layout_width="100dp"
          android:layout_height="wrap_content"
          android:layout_below="@id/host_label"
          android:layout_marginTop="4dp"
          android:layout_toRightOf="@id/host_input"
          android:background="@android:drawable/editbox_background"
          android:inputType="number" /&gt;
  
      &lt;TextView
          android:id="@+id/username_label"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_below="@+id/host_input"
          android:paddingLeft="15dp"
          android:paddingTop="15dp"
          android:text="username"
          android:textColor="#a5d4e2"
          android:textSize="25sp"
          android:textStyle="normal" /&gt;
  
      &lt;EditText
          android:id="@+id/username_input"
          android:layout_width="fill_parent"
          android:layout_height="wrap_content"
          android:layout_below="@id/username_label"
          android:layout_marginLeft="15dp"
          android:layout_marginRight="15dp"
          android:layout_marginTop="4dp"
          android:background="@android:drawable/editbox_background"
          android:inputType="textEmailAddress" /&gt;
  
      &lt;TextView
          android:id="@+id/password_label"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_below="@+id/username_input"
          android:paddingLeft="15dp"
          android:paddingTop="15dp"
          android:text="password"
          android:textColor="#a5d4e2"
          android:textSize="25sp"
          android:textStyle="normal" /&gt;
  
      &lt;EditText
          android:id="@+id/password_input"
          android:layout_width="fill_parent"
          android:layout_height="wrap_content"
          android:layout_below="@id/password_label"
          android:layout_marginLeft="15dp"
          android:layout_marginRight="15dp"
          android:layout_marginTop="4dp"
          android:background="@android:drawable/editbox_background"
          android:inputType="textPassword" /&gt;
  
      &lt;ImageView
          android:id="@+id/home"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_alignParentTop="true"
          android:layout_centerHorizontal="true"
          android:layout_centerVertical="false"
          android:paddingLeft="15dp"
          android:paddingRight="15dp"
          android:paddingTop="15dp"
          android:scaleType="fitStart"
          android:src="@drawable/home" /&gt;
  
      &lt;Button
          android:id="@+id/login_button"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_below="@+id/password_input"
          android:layout_marginLeft="15dp"
          android:layout_marginTop="15dp"
          android:text="   login   "
          android:textSize="18sp" &gt;
      &lt;/Button&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>