android: string format specify bold

后端 未结 7 674
半阙折子戏
半阙折子戏 2021-01-05 05:05

I have a string defined in string.xml like

Title: %1$s 

which is formatted us

7条回答
  •  半阙折子戏
    2021-01-05 05:39

    Now, it is reasonably supported by Android.

    you can define the string in xml as Hey <b>This is in bold</b>

    Then in code, use this to convert to CharSequence and then use it for e.g in TextView

    String text = getResources().getString(R.string.text-to_show);
    CharSequence styledText = Html.fromHtml(text);
    textview.setText(styledText);
    

提交回复
热议问题