如何影响 Android Textview 中的换行符

发布于 2024-12-17 06:20:50 字数 375 浏览 4 评论 0原文

我有一个应用程序小部件,显示距离以下事件还有几天:

事件名称(-231 天)

如果可能的话我想在一行中显示这个字符串。 如果事件名称太长,我想将大括号中的完整术语显示到新行中。 所以它就像:

长事件名称
(-231 天)

而不是:

长事件名称 (-231
天)

(或类似的东西)

有办法存档吗? 我可以使(-231天)“原子”吗?

string.getLength 不起作用,因为小部件的大小会因设备而异。

I have an Appwidget displaying days until an event like:

eventname (-231 days)

If possible I want to display this String in one line.
If the eventname is too long I want to display the full term in braces into a new line.
So that it is like:

longeventname
(-231 days)

instead of:

longeventname (-231
days)

(or anything similar)

Is there a way to archive this?
Can I make (-231 days) "atomic"?

string.getLength won't work since the size of the widget will vary by device.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

栀子花开つ 2024-12-24 06:20:50

您可以在数字和“天”之间使用不间断空格

对于 XML 中的字符串,它是  ;对于 Java 代码中的字符串,它是 \u00A0

You could use a non-breaking space between the number and "days".

That's   for a string in XML, or \u00A0 for a string in Java code.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文