Android 中的断字 [英] Hyphenation in Android
问题描述
作为国际化 Android 应用程序的一部分,我遇到了在正确位置动态换行或断字的需要.
As part of internationalizing an Android application I have come across the need to dynamically word wrap or hyphenate at the right position.
我的所有字符串都在 strings.xml 文件中进行了外部化,但我没有找到任何关于 Android 中的断字的文档.
All my strings are externalized in strings.xml files but I have not found any documentation about hyphenation in Android.
我希望能够建议类似于我在 LaTeX 中的连字符位置:
I would like to be able to suggest hyphenation positions similar to how I can do it in LaTeX:
http://en.wikipedia.org/wiki/Hyphenation_algorithm
但我没有发现任何迹象表明这是否可行.我错过了框架中的任何内容吗?其他人在做什么?用没有明显位置的日文字符串打断句子?你只是在正确的位置添加空格吗?
But I have not found any indication if this is possible. Is there anything in the framework I have missed? What are other people doing e.g. with Japanese strings that have no obvious position to break up a sentence? Do you just add spaces at the correct positions?
我可以动态调整字体大小以适应某些布局,但对于跨越多行的较长消息不起作用.怎么办?
I could dynamically size the font to fit into certain layouts but for longer messages that go across multiple lines that won't work. What to do?
推荐答案
它是 Android 6 Marshmellow 的新事物.
Its a new thing from Android 6 Marshmellow.
尝试将此添加到您的 TextView xml
Try adding this to your TextView xml
android:hyphenationFrequency="none"
这篇关于Android 中的断字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!