1

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?

4

1 回答 1

1

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.

于 2013-09-05T13:54:10.060 回答