问题描述
我需要的TextView漂亮的文本换行,尤其是在头文字。
I need nice text wrapping in TextView, especially for text in headers.
有关TextView的文字换行可能是这样的,在这里的最后一个字是新行:
Text wrapping for TextView might look like this, where the last word is in new line:
| ========================= |
| ===== |
这是什么,我想有被包裹其中,线的宽度更平和:
That what I would like to have is wrapping where lines width is more equable:
| ================ |
| ============== |
这很容易添加的'\\ n'的一种语言测试它在不同的屏幕尺寸,但不是当有超过10个的翻译。
It's easy to add '\n' for one language and test it on different screen sizes but not when there is more than 10 translations.
推荐答案
我已经修改的TextView创造UniformTextView。 TextView的的来源调查后,我决定尽量减少TextView的宽度有preferred行数。
I have modified TextView and created UniformTextView. After investigating of TextView sources I have decided to minimize TextView's width to have preferred lines number.
<pl.dziobas.uniformtextview.UniformTextView
android:text="@string/sample_text"
android:layout_height="wrap_content"
android:layout_width="match_parent"
app:prefLineNumber="2"
style="@style/sample_style" />
它的工作满意我。结果
It works satisfactorily for me.
源代码可以在
这篇关于在TextView的统一文本换行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!