将多行html文本居中对齐到textview

时间:2017-02-22 09:03:26

标签: android textview android-styles

我有以下要设置为TextView的html代码。我希望第二行是居中对齐的。即使添加左边填充后,我也看不到文本与中心对齐。

String title = "<span style='font-family:Avenir Roboto Regular; font-size:16pt'>Howdy doing.<br></span><span style='font-family:Roboto Regular; font-size:16pt'>Doing great:</span>"


if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
        textview.setText(Html.fromHtml(title, Html.FROM_HTML_MODE_LEGACY));
    } else {
        textview.setText(Html.fromHtml(title));
    }

0 个答案:

没有答案