TextView Ellipsize not working

Below TextView is defined in xml.

     <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:hint="Select Language"
            android:singleLine="true"
            android:maxLines="1"
            android:maxLength="30"
            android:ellipsize="end"
            android:padding="4dp"
            android:textAppearance="?android:textAppearanceMedium"
            android:textColor="@android:color/holo_blue_dark"
            android:id="@+id/selected_language" />

      

I want to ellipse the text when the text is more than 30 characters long, but its not working at all. Check if I am missing anything. I tried the answers posted for a similar question, but it didn't work.

+3


source to share


3 answers


I have MaxLength for MaxEms in your TextView, this works now.



<TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:hint="Select Language"
            android:singleLine="true"
            android:maxLines="1"
            android:maxEms="30"
            android:ellipsize="end"
            android:padding="4dp"
            android:textAppearance="?android:textAppearanceMedium"
            android:textColor="@android:color/holo_blue_dark"
            android:id="@+id/selected_language" />

      

+2


source


ellipsize doesn't work, based on the max length it will work with the width of your text.



In your code, you will mention as maxlength 30 so try specifying the width of the textview.

+2


source


Thanks for the answer. I removed the maxLength attribute and set its width to match_parent.its, which works now.       

0


source







All Articles