如何在Textview中对齐文本宽度?

时间:2017-10-26 09:53:12

标签: android android-layout text textview android-xml

我希望将TextView中的文字与此对齐

enter image description here

我目前的textView外观就像

enter image description here

如何在不使用text layout

的情况下实现Webview

2 个答案:

答案 0 :(得分:2)

Android O中的

TextView提供完整的理由(新的排版对齐)本身。

你只需要这样做,

textView.setJustificationMode(JUSTIFICATION_MODE_INTER_WORD);
default is JUSTIFICATION_MODE_NONE

答案 1 :(得分:1)

您可以使用:

https://github.com/bluejamesbond/TextJustify-Android

安装只需添加到 build.gradle

即可
dependencies {
    compile 'com.github.bluejamesbond:textjustify-android:2.1.6'
}

使用:https://github.com/Saleh-Hassan/RTL-TextJustify-Android

示例:

enter image description here

enter image description here