如何影响 Android Textview 中的换行符
我有一个应用程序小部件,显示距离以下事件还有几天:
事件名称(-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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以在数字和“天”之间使用不间断空格。
对于 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.