【问题标题】:Resizing TextView does not shrink its height on Android 3.1在 Android 3.1 上调整 TextView 的大小不会缩小其高度
【发布时间】:2011-08-08 17:56:45
【问题描述】:

我有一个TextView,可以动态调整大小(我使用setTextSize())。它在 Android 2.2 上正确地扩展和收缩了它的界限。但是在Android 3.1上,当文字变小时,区域的高度并没有缩小。

Here is the short video 证明了这一点。

布局只是简单的垂直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 在 Honeycomb 上的字体大小相应地减小其高度,还需要做些什么?

PS。同样,在 Android 2.2 上,文本区域会折叠到最小高度,没有任何问题。 The video how it's intended to work.

【问题讨论】:

    标签: android resize textview


    【解决方案1】:

    可能有点晚了,它来自一个错误

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

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

    但有一种解决方法是在文本末尾附加一个非宽度字符。

    任何这些工作

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

    【讨论】:

      【解决方案2】:

      我知道这是一个旧线程。

      但是上面列出的所有这些字符对我来说都不能正常工作,我在 5.0.1 中遇到了这个问题,解决方法是将 textview 重力设置为垂直中心。

      希望这对任何人都有帮助:)

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2012-02-05
        • 1970-01-01
        • 1970-01-01
        • 2012-09-23
        • 2013-10-09
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多