Android TextView Justify Text

前端 未结 29 1818
滥情空心
滥情空心 2020-11-22 03:28

How do you get the text of a TextView to be Justified (with text flush on the left- and right- hand sides)?

I found a possible solution here, but it do

29条回答
  •  我寻月下人不归
    2020-11-22 04:00

    TextView in Android O offers full justification (new typographic alignment) itself.

    You just need to do this:

    Kotlin

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
        textView.justificationMode = JUSTIFICATION_MODE_INTER_WORD
    }
    

    Java

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
        textView.setJustificationMode(JUSTIFICATION_MODE_INTER_WORD);
    }
    

    default is JUSTIFICATION_MODE_NONE.

提交回复
热议问题