Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TextView Ellipsize not working

Below is TextView 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 ellipsize text when text length is greater than 30 chars but its not working at all.please check if i am missing anything.i tried answers posted for similar question but it did not work.

like image 839
virtual6 Avatar asked Nov 20 '25 06:11

virtual6


1 Answers

I have Changed MaxLength to MaxEms in your TextView its Working now use this.

<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" />
like image 82
Divyang Panchal Avatar answered Nov 21 '25 18:11

Divyang Panchal



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!