Skip to content Skip to sidebar Skip to footer

Android - Ellipsize="end" Not Showing Three Dots

I'm working on a TextView which is contained in a ConstraintLayout. I want ellipsize to add three dots at the end of text(in the TextView) if its length exceeds maxLength. maxLines

Solution 1:

The problem is:

android:maxLength="24"

remove it since you want the TextView to be ellipsized. A TextView gets ellipsized when it is not wide enough to show the whole text. I think you do not understand what this attribute android:ellipsize="end" is all about. If it is wide enough then you will not see any dots at the end because they are not needed. If you set android:layout_width="40dp" then you will see the dots. With android:layout_width="wrap_content" the TextView is wide enough and it is not ellipsized.

Solution 2:

1) Add one more property android:singleLine="true" in your Textview

(But its Deprecated so use second option)

2) Use this three together

android:maxLines="1"android:scrollHorizontally="true"android:ellipsize="end"

Solution 3:

Ellipsize is quite a pain in android, apply below on your textView :

txtDescription.setSingleLine(true);

Hope it helps.

Solution 4:

The key for making three dots shows is constrain the width of the text view. Suppose the name of image in your posted figure is left_image, change the xml attributes of TextView as below:

....
android:layout_width="0dp"app:layout_constraintStart_toEndOf="@+id/left_image"
....

above two lines make the width of TextView is constrainted(between left img and right border of parent).

Solution 5:

In my case following line was the problem. I commented it out and it worked.

<itemname="android:inputType">text|textNoSuggestions</item>

Post a Comment for "Android - Ellipsize="end" Not Showing Three Dots"