title: android:layout_gravity doesn't work as expected
body: <p>I have a simple LinearLayout with one TextView and one ImageView. I want the text in the TextView to be aligned to the right, but the result show that the Text was aligned to the left. Is there anything wrong with my layout xml? Thanks.</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:orientation="vertical" android:layout_width="fill_parent"
      android:layout_height="wrap_content" android:background="#E8E3E4"&gt;
      &lt;LinearLayout android:orientation="horizontal"
          android:layout_width="wrap_content" android:layout_height="wrap_content"
          &gt;
          &lt;TextView android:layout_width="260dp" android:layout_height="wrap_content"
              android:text="More Comments" android:textStyle="bold" android:background="#ff0000"
              android:textColor="#121222" android:layout_gravity="right" /&gt;
          &lt;ImageView android:layout_width="50dp"
              android:layout_height="wrap_content" android:src="@drawable/arrow_right"
              android:layout_gravity="center" android:scaleType="centerInside" /&gt;
      &lt;/LinearLayout&gt;
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <hr>
  
  <p>Thanks, Michael. But the workaround you mentioned doesn't work either.</p>
  
  <p>I tried to use RelativeLayout, but it still gave me result like:
  More Comments             (Icon)</p>
  
  <p>What I expected is 
              More Comments (Icon)</p>
  
  <p>The RelativeLayout xml is below. Is there anything wrong with it?</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_width="fill_parent" android:layout_height="fill_parent"&gt;
      &lt;TextView android:id="@+id/label" android:layout_width="260dp"
          android:layout_height="wrap_content" android:text="More Comments"
          android:textStyle="bold" android:background="#ff0000"
          android:textColor="#121222" android:layout_gravity="right" /&gt;
      &lt;ImageView android:layout_width="50dp" android:layout_height="wrap_content"
          android:src="@drawable/arrow_right" android:layout_gravity="center"
          android:scaleType="centerInside" android:layout_toRightOf="@id/label" /&gt;
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <hr>
  
  <p>Following the workaround in Michael's comment, I have the XML below. I expected the output to be:</p>
  
  <pre><code>     RightLeft
  </code></pre>
  
  <p>but the actual output is:</p>
  
  <pre><code>Right             Left
  </code></pre>
  
  <p>So the workaround doesn't work for me. Any thoughts?</p>
  
  
  
  <p></p>
  
  <pre><code>   &lt;LinearLayout android:orientation="horizontal"
              android:layout_width="fill_parent"
              android:layout_height="wrap_content"&gt;
             &lt;TextView
                     android:layout_width="wrap_content"
                     android:layout_height="wrap_content"
                     android:layout_gravity="right"
                     android:layout_weight="1.0"                       
                     android:text="RIGHT"/&gt;
             &lt;TextView
                     android:layout_width="wrap_content"
  
                     android:layout_height="wrap_content"
                     android:layout_gravity="left"
                     android:text="LEFT"/&gt;
     &lt;/LinearLayout&gt;
  </code></pre>
  
  <p> </p>