带有 wrap_contents 的斜体 TextView 似乎在右边缘剪辑文本 [英] Italic TextView with wrap_contents seems to clip the text at right edge

查看:9
本文介绍了带有 wrap_contents 的斜体 TextView 似乎在右边缘剪辑文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<TextView android:id="@+id/prodLbl"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerHorizontal="true"
    android:layout_centerVertical="true"
    android:textColor="#FFFFFF"
    android:textSize="30dip"
    android:textStyle="italic"
    android:text="Magnifico"
    />

似乎从最右边的字符中剪掉了几个像素,至少在 480x800 模拟器或 Nexus One 上是这样.

Seems to clip few pixels from the rightmost character, at least on 480x800 emulator or Nexus One.

对我来说,这看起来像是一个错误,但我只是一个 Android 初学者.我试图在左右两边添加边距,但它仍然在剪裁.最后,我的破解方法是在文本的两侧添加一个空格.还有其他解决方案吗?

To me it looks like a bug, but I'm just an Android beginner. I tried to add margins to left and right, but it still kept on clipping. In the end my hack around it was to add a single space on both sides of the text. Any other solutions?

推荐答案

android:layout_width="wrap_content" ,为您提供一个用于包装内容渲染的矩形.一切都适用于普通文本(非斜体).

android:layout_width="wrap_content" , gives you a rectangle for wrapped content rendering. All will work well for normal text (non-italic).

启用 italic 文本后,换行的文本将尝试适合矩形,因此最右边的字符将被截断,除非其不可截断(例如 .)1等)

Once you have italic text enabled, the wrapped text will try to fit into the rectangle and hence the rightmost character will be cut off unless its un-cut-able (such as ., ), 1, etc.)

建议的解决方案是在文本末尾留一个空格(或者更好的??)

Solution as suggested is to have a space at the end of the text (or anything better ??)

PS: 这也适用于 android:gravity="right" 因为文本将被推到最右边.如果我们有 italic 文本,我们将面临同样的问题.

PS: This applies to android:gravity="right" too because the text will be pushed to the rightmost. If we have italic text, we face the same problem.

这篇关于带有 wrap_contents 的斜体 TextView 似乎在右边缘剪辑文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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