Android TextView Singleline With Ellipsis

June 18, 2018
<TextView
    android:id="@+id/titleTextView"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:textAppearance="?android:attr/textAppearanceLarge"
    android:singleLine="true"
    android:ellipsize="marquee"
    tools:text="Title"
    />

NOTE: Is xml singleLine attribute deprecated? Refer to singleLine doc.

If you try to use maxLines=1 with ellipsize, you shall get the following lint error (refer to this discussion)

Combining ellipsize and maxLines=1 can lead to crashes on some devices. Earlier versions of lint recommended replacing singleLine=true with maxLines=1 but that should not be done when using ellipsize

This work is licensed under a
Creative Commons Attribution-NonCommercial 4.0 International License.