Prevent a multiline TextView from unnecessarily expanding to it's maximum width
<p>A TextView that expands to multiple lines seems to automatically expand to fit it's maximum possible width.  How can I prevent that from happening?</p>

<p>Here is an example layout (test.xml)</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="match_parent"
android:layout_height="match_parent"
android:background="@color/white"&gt;
&lt;TextView
android:background="@color/green"
android:layout_alignParentRight="true"
android:id="@+id/foo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="right"
android:text="This is the message a much shorter message"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="@color/black" /&gt;
&lt;/RelativeLayout&gt;
</code></pre>

<p><img src="http://i.imgur.com/er5zr.png" alt="TextView shown with maximum width"></p>

<p>If I add a margin on the left, it correctly shrinks the width of the TextView (without reformatting the content), but the size of the margin would have to calculated given the contents of the TextView.</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="match_parent"
android:layout_height="match_parent"
android:background="@color/white"&gt;
&lt;TextView
android:layout_marginLeft="32dp"
android:background="@color/green"
android:layout_alignParentRight="true"
android:id="@+id/foo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="right"
android:text="This is the message a much shorter message"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="@color/black" /&gt;
&lt;/RelativeLayout&gt;
</code></pre>

<p><img src="http://i.imgur.com/neq7V.png" alt="TextView show with margin"></p>
