Reputation: 725
My textview is wrapping text despite the settings lines="1"
and ellipsise="end"
. What do I need to do in addition to prevent the line wrapping hand have the text ellipsised with a "..." as intended?
<TextView
android:id="@+id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/date"
android:background="@color/listHeaderBackground"
android:ellipsize="end"
android:gravity="left|center_vertical"
android:height="30dp"
android:lines="1"
android:maxLines="1"
android:paddingBottom="3dp"
android:paddingLeft="20dp"
android:paddingRight="7dp"
android:paddingTop="3dp"
android:text="New Ion Beam Etcher ordered blah blah blah blah"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@color/listHeaderForeground" />
see the third item: "New sputter tool" etc.
Upvotes: 24
Views: 21908
Reputation: 949
Add the following to your TextView definition:
android:maxLines="1"
Upvotes: 36
Reputation: 2749
The option shown below is deprecated
android:singleLine="true"
Instead use this:
android:maxLines="1"
Upvotes: 9
Reputation: 6438
From TextView Ellipsize (...) not working :
<TextView android:id="@+id/lName"
android:style="@style/autoscroll" />
And in your style.xml
<style name="autoscroll">
<item name="android:singleLine">true</item>
<item name="android:ellipsize">marquee</item>
<item name="android:marqueeRepeatLimit">marquee_forever</item>
<item name="android:focusable">true</item>
<item name="android:focusableInTouchMode">true</item>
<item name="android:scrollHorizontally">true</item>
</style>
Upvotes: 1