GrAnd
GrAnd

Reputation: 10211

Resizing TextView does not shrink its height on Android 3.1

I have a TextView which can be resized dinamically (I use setTextSize()). It correctly expands and shrinks its bounds on Android 2.2. But on Android 3.1, when the text become smaller, the height of area is not shrink.

Here is the short video that demonstrates that.

The layout is just simple vertical LinearLayout:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="0dip">
... 
<TextView 
    android:id="@+id/track_number" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content"
    style="@style/tcTrackNo" 
    android:padding="5dp" />
    ...


<style name="tcTrackNo" parent="@android:style/TextAppearance.Small">
    <item name="android:textColor">@color/track_number</item>
</style>

So, what extra should be done to make the TextView reduce its height accordingly to its font size on Honeycomb?

PS. Again, on Android 2.2 the text area collapses until the smallest height without any issue. The video how it's intended to work.

Upvotes: 2

Views: 736

Answers (2)

Khalid Abdlqader
Khalid Abdlqader

Reputation: 309

i know this is an old thread.

but all these characters listed above did not worked properly with me, i faced this issue with 5.0.1 and the fix was to set the textview gravity to center vertical.

hope this help anyone :)

Upvotes: 0

pt123
pt123

Reputation: 2166

Might be a bit late it's from a bug

http://code.google.com/p/android/issues/detail?id=17343

http://code.google.com/p/android/issues/detail?id=22493

But there is a workaround by appending a non width character at the end of your text.

Any of these work

final String DOUBLE_BYTE_SPACE = "\u3000";
final String DOUBLE_BYTE_WORDJOINER = "\u2060";
final String ZERO_WIDTH_SPACE = "\u200b";
textview.append(ZERO_WIDTH_SPACE);              

Upvotes: 1

Related Questions