I have a TextView set to ellipsize but when I put the text in it doesn\'t do so. Any ideas?
You change your layout_width to certain dp instead of wrap_content
and
use
android:singleLine="true"
android:ellipsize="end"
code:
android:layout_width="50dp"
android:layout_height="wrap_content"
android:text="check this text"
android:id="@+id/textView"
android:singleLine="true"
android:ellipsize="end"/>
You need to match the settings for android can correctly calculate the position of the object. Has several possible combinations, and depends on the rest of the layout is on the same line.
This is a combination that works:
android:layout_width="0dip" // dynamic width
android:layout_weight="1" // less weight, other objects still "0"
android:ellipsize="end" // ... into end of text (right)
android:singleLine="true" // one line, deprecated, but necessary for some ambients
android:maxLines="1" // one line, new mode
In summary, you indicate the weight, if you use dynamic layout, or just a fixed size, then indicates to only have one line and configures how "..." is displayed.
This solution works:
android:ellipsize="end"
android:singleLine="false"
android:lines="3"
android:maxLines="3"
Width can also be set to "wrap_content"
My app started ignoring maxlines & ellipsize when I added
android:textIsSelectable="true"
It seems like these options are not compatible together.
If you aren't defining a specific width for your TextView
the text will ellipsize first when your text is reaching the parent view's width.
Try:
android:singleLine="true"