TMH
TMH

Reputation: 6246

TextView not Ellipsizing

I have this TextView

<TextView
    style="@style/ellipsize"
    android:text="@string/alphabet"
    android:id="@+id/class_name"
    android:layout_toRightOf="@id/is_alt"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" />




<style name="ellipsize">
    <item name="android:singleLine">true</item>
    <item name="android:maxEms">5</item>m>
    <item name="android:maxLength">5</item>
    <item name="android:maxLines">1</item>
    <item name="android:ellipsize">end</item>
</style>

However the text doesn't ellipsize, it just stops. E.g. the above give just abcde, rather than abcde...

What have I got wrong?

Upvotes: 1

Views: 754

Answers (1)

Ritaban
Ritaban

Reputation: 773

Give a particular width to your textView like 50 dip or 60dip. If you restrict the textView to 5 chars it will show only 5 chars. The main logic for ellipsize is if your text is too long to be accomodated in the text view then only it will ellipsize. Remove maxlength and maxEMS and try givinga longer text after assigning the textview a fixed width.

Upvotes: 1

Related Questions