androidtextviewandroid-4.0-ice-cream-sandwich

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);

Solution

  • 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!