TextView Ellipsize (...) not working

Add this in your xml for the TextView:

        android:maxWidth="200dp" 
        android:maxLines="1" 

As

        android:singleLine="true"  

is deprecated.


android:id="@+id/lName" android:layout_width="150dp"
    android:layout_height="wrap_content"
    android:ellipsize="end"
    android:singleLine="true"
    android:text="Avinljhakjhsajkhakjshda"
    android:textSize="16sp"

Add the following styles in your styles file (typically styles.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>

Then add the style @style/autoscroll to your TextView:

<TextView android:id="@+id/lName"
      style="@style/autoscroll" />

You can reuse your autoscroll feature easily when you want this way.


This doesn't work with me unless adding 'android:ems' attribute along with the android:ellipsize attribute

android:ellipsize="end"
android:singleLine="true"
android:ems="8"