How to truncate TextView, and then add ellipsis in Android
<p>I have read a few of the other threads here with similar concerns, but none of their answers seemed to work for me.</p>

<p><a href="http://stackoverflow.com/questions/1698881/cant-get-ellipsis-to-work-on-android">Can&#39;t get ellipsis to work on Android</a></p>

<p><a href="http://stackoverflow.com/questions/3769105/android-something-better-than-androidellipsize-end-to-add-to-truncated">Android: Something better than android:ellipsize=&quot;end&quot; to add &quot;...&quot; to truncated long Strings?</a></p>

<p>I have a Relative Layout with 2 elements, a text view and an image view. I need the text view to be 1 line and to truncate about 5sp short of the image view and apply ellipsis to the end of the text. </p>

<pre><code>&lt;RelativeLayout
                android:id="@+id/title_close"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginTop="5sp"&gt;

                &lt;TextView
                    android:id="@+id/"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_alignParentLeft="true"
                    android:textSize="10sp"
                    android:textColor="#FFFFFF"
                    android:text="title"
                    android:maxLines="1"
                    android:ellipsize="end"/&gt;

                &lt;ImageView
                    android:id="@+id/"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_alignParentRight="true"
                    android:layout_marginRight="5sp"
                    android:layout_marginLeft="5sp"
                    android:background="@drawable/home"/&gt;

&lt;/RelativeLayout&gt;
</code></pre>

<p>In the above code, I was attempting to apply a margin left to the Image View to force the text view to its left to truncate by as many sp as I put in the margin. </p>

<p>The code above would truncate the text view to a single line and add (...) but only to the end of that line; irrespective of the ImageView to it's right, regardless of whatever margin I apply to it. The Image View appears above the text. I figured this may be due to them being in a relative layout.</p>

<p>Any help in figuring out how to make the text view respect the margin/space taken up by the image view would be greatly appreciated.</p>
