how to have bold and normal text in same textview in android?

前端 未结 7 1179
终归单人心
终归单人心 2021-02-18 23:48

I have searched internet and tried the following code but its not working

SpannableString ss1 = new SpannableString(\"Health: \");
           ss1.setSpan(new and         


        
7条回答
  •  攒了一身酷
    2021-02-19 00:40

    The easiest way is

    textview1.setText(Html.fromHtml("Health: good"));
    

    The mistake in your code is to use string concatenation here: "\n"+ss1+strhealth+"\n\n" which strips out all formatting because the components are taken as normal strings.

提交回复
热议问题