Android TextView Justify Text

前端 未结 29 1226
滥情空心
滥情空心 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条回答
  •  -上瘾入骨i
    2020-11-22 04:19

    FILL_HORIZONTAL is equivalent to CENTER_HORIZONTAL. You can see this code snippet in textview's source code:

    case Gravity.CENTER_HORIZONTAL:
    case Gravity.FILL_HORIZONTAL:
        return (mLayout.getLineWidth(0) - ((mRight - mLeft) -
                getCompoundPaddingLeft() - getCompoundPaddingRight())) /
                getHorizontalFadingEdgeLength();
    

提交回复
热议问题