Reputation: 35
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.
Upvotes: 3
Views: 2844
Reputation: 35
Thanks for the answer. i removed the maxLength attribute and set its width to match_parent.its working now.
Upvotes: -1
Reputation: 56
ellipsize wont work based on the max length it will work width of your textview.
In your code you mention like maxlength 30 so try to specify width of textview.
Upvotes: 2
Reputation: 1909
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" />
Upvotes: 2