MikeIsrael
MikeIsrael

Reputation: 2889

ellipse ice cream sandwich adds [

I am currently developing an app and just ran some testing on ice cream sandwich and noticed some odd behavior when using the property android:ellipsize="end" in a textview. it is adding a [ character after the dots. This bug is driving me nuts and only appearing in ice cream sandwich. I saw a previous thread about this, but none of the fixes there helped. Any ideas, but report for android 4.0, maybe? My code below incase I am wronging ice cream sandwich somehow.

 <LinearLayout
     android:id="@+id/mainTitleLayout"
     android:layout_width="wrap_content"
     android:layout_height="fill_parent"
     android:layout_weight="0.36"
     android:orientation="horizontal"
     android:weightSum="1" >
<TextView
    android:id="@+id/mainTitle"
    android:layout_width="135dp"
    android:layout_height="wrap_content"
    android:layout_marginLeft="62dp"
    android:layout_marginTop="4dp"
    android:layout_weight="0.53"
    android:editable="false"
    android:ellipsize="end"
    android:gravity="center_vertical|center_horizontal"
    android:singleLine="true"
    android:textColor="#fff"
    android:textSize="26sp"
    android:textStyle="bold"
    android:width="125dp" >
</TextView>
</LinearLayout>

I set the text dynamically in code via

TextView title = (TextView) act.findViewById(R.id.mainTitle);
title.setTypeface(Utils.font);
title.setText(detailTitle);

Upvotes: 4

Views: 1255

Answers (3)

Shine
Shine

Reputation: 3818

If I were you, I would try minLines and maxlines inside TextView declaration, this way:

android:minLines="1"
android:maxLines="1"

instead of android:singleLine="true". I had a similar problem, that emerged only when using android 4. I solved this way, but I didn't change the font via setTypeface.

Upvotes: 0

icecreamman
icecreamman

Reputation: 611

I think I know your problem. I have discovered this problem with my custom font that I set via setTypeface. The answer is found in the source code for Layout, which handles the drawing of TextViews to the screen. Take a look at the method 'ellipsize' at ling 1668. It appears to use a character, the 0-width space (U+FEFF), in addition to the ellipsis character. My guess is that your custom font does not include the 0-width space character, this causing the box to render. I have the same problem! The fix would necessitate altering the .ttf or .otf file to include the 0-width space character. Hope this helps!

Upvotes: 6

Sara
Sara

Reputation: 11

I had a similar problem using a custom font in a TextView, actually in 1.6. In my case, I replaced the standard TextView with the version in this link:

android ellipsize multiline textview

and the extra characters went away.

Upvotes: 1

Related Questions