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

前端 未结 7 1181
终归单人心
终归单人心 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:42
     String txt1="Health: ";
     SpannableString txtSpannable= new SpannableString(txt1);
     StyleSpan boldSpan = new StyleSpan(Typeface.BOLD);
     txtSpannable.setSpan(boldSpan, 0, 8, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
    
     builder.append(txtSpannable);
    
     String txt2="good";
     builder.append(txt2);
    
     textview1.lblStatus.setText(builder, TextView.BufferType.SPANNABLE);
    
    0 讨论(0)
提交回复
热议问题