调整大小的TextView不收缩其高度在Android 3.1 [英] Resizing TextView does not shrink its height on Android 3.1

查看:139
本文介绍了调整大小的TextView不收缩其高度在Android 3.1的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个的TextView 可以dinamically调整大小(我用 setTextSize())。它正确地膨胀和收缩它的界限在Android 2.2。但在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.

这里是简短的视频的证明。

布局仅仅是简单的垂直的LinearLayout

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>

那么,什么额外的应该怎样做才能使的TextView 相应地降低其高度在蜂窝其字体大小?

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

PS。再次,在Android 2.2文本区塌陷,直到最小的高度,没有任何问题。 视频它是如何打算的工作

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.

推荐答案

可能有点晚了它是从错误

Might be a bit late it's from a bug

HTTP://$c$c.google。 COM / P /安卓/问题/详细信息?ID = 17343

HTTP://$c$c.google。 COM / P /安卓/问题/详细信息?ID = 22493

但有一种变通方法通过在你的文本的末尾附加一个非宽字符。

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

所有这些工作

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

这篇关于调整大小的TextView不收缩其高度在Android 3.1的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆