title: Aligning right and left with linear or relativelayout with truncated text?
body: <p>I am trying to do a listview which looks like this:
  <a href="https://i.stack.imgur.com/v5s64.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/v5s64.jpg" alt="alt text"></a><br>
  <sub>(source: <a href="http://pici.se/pictures/hjFksZvLx.jpg" rel="nofollow noreferrer">pici.se</a>)</sub>  </p>
  
  <p>It has two parts, the left is left-aligned and contains two textviews which are single line and truncated.
  The right is part also has two textviews but they are right-aligned and have constant size. The main problem is that the right part does not align to the right.
  If I use a static width to push it to the right side it works pretty good, but then it does not look good in landscape mode.</p>
  
  <p>I thought it should be simple to accomplish. But it wasn't.</p>
  
  <p>First I tried with Linearlayout:</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="fill_parent"
      android:layout_height="wrap_content"
      android:orientation="horizontal"&gt;
      &lt;LinearLayout
          android:orientation="vertical"
          android:id="@+id/L1"
          android:layout_height="fill_parent"
          android:layout_weight="0.8"
          android:layout_width="0dip"&gt;
          &lt;TextView
              android:id="@+id/text1"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:lines="1"
              android:ellipsize="end"
              android:scrollHorizontally="true"
              android:text="Long text Long text Long text Long text Long text Long text Long text" /&gt;
          &lt;TextView
              android:id="@+id/text2"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:lines="1"
              android:ellipsize="end"
              android:scrollHorizontally="true"
              android:text="Short text" /&gt;
      &lt;/LinearLayout&gt;
      &lt;LinearLayout
          android:orientation="vertical"
          android:id="@+id/L2"
          android:layout_gravity="top|right"
          android:layout_height="fill_parent"
          android:layout_weight="0.2"
          android:layout_width="0dip"&gt;
          &lt;TextView
              android:id="@+id/text4"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_gravity="right"
              android:text="12:12" /&gt;
          &lt;TextView
              android:id="@+id/text3"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:text="64%"
              android:layout_gravity="right" /&gt;
      &lt;/LinearLayout&gt;
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>I have been fiddling with the weight property, but it doesn't seem to help. Right part does not align to the right at all.</p>
  
  <p>And then I tried with Relativelayout:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;RelativeLayout
      xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_height="wrap_content"
      android:layout_width="fill_parent"&gt;
      &lt;TextView
          android:id="@+id/text1"
          android:layout_height="wrap_content"
          android:lines="1"
          android:scrollHorizontally="true"
          android:layout_alignParentTop="true"
          android:text="Long text Long text Long text Long text Long text Long text Long text"
          android:layout_alignParentLeft="true"
          android:ellipsize="end"
          android:layout_width="275dp" /&gt;
      &lt;TextView
          android:id="@+id/text2"
          android:layout_height="wrap_content"
          android:lines="1"
          android:ellipsize="end"
          android:scrollHorizontally="true"
          android:text="Long text Long text Long text Long text Long text Long text Long text"
          android:layout_below="@+id/text1"
          android:layout_alignParentLeft="true"
          android:layout_width="275dp" /&gt;
      &lt;TextView
          android:id="@+id/text3"
          android:layout_height="wrap_content"
          android:text="12:12"
          android:layout_gravity="right"
          android:layout_alignParentRight="true"
          android:layout_alignBaseline="@+id/text1"
          android:layout_width="40dp"
          android:layout_alignRight="@+id/text4" /&gt;
      &lt;TextView
          android:id="@+id/text4"
          android:layout_height="wrap_content"
          android:layout_gravity="right"
          android:text="64%"
          android:layout_alignParentRight="true"
          android:layout_alignBaseline="@+id/text2"
          android:layout_width="40dp" /&gt;
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>Same problem here, the right part is not aligning to the the right properly, and I have to use a static size of android:layout_width to push it to the other side.
  And if don't use a static size the text start clipping each other.</p>