在 Android 3.1 上调整 TextView 大小不会缩小其高度
我有一个可以动态调整大小的 TextView(我使用 setTextSize())。它在 Android 2.2 上正确扩展和收缩其边界。但在Android 3.1上,当文本变小时,区域的高度不会缩小。
布局只是简单的垂直 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 上的字体大小相应地降低其高度呢?
附言。同样,在 Android 2.2 上,文本区域会折叠到最小高度,没有任何问题。 视频的工作原理。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
可能有点晚了
由于错误http://code.google, 。 com/p/android/issues/detail?id=17343
http://code.google.com/p/android/issues/detail?id=22493
但是有一种解决方法,可以在文本末尾附加一个非宽度字符。
任何这些工作
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
我知道这是一个旧线程。
但上面列出的所有这些字符对我来说都不能正常工作,我在 5.0.1 中遇到了这个问题,解决方法是将 textview 重力设置为垂直中心。
希望这对任何人都有帮助:)
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 :)