Is it possible to change the text color in a string to multiple colors in Java?

后端 未结 9 1847
暗喜
暗喜 2020-11-27 04:37

What I mean is, is it possible to change the text \"This text is blue\" to the color blue in a single string? There must be a way...



        
9条回答
  •  天涯浪人
    2020-11-27 05:14

    I am use for a change star if service "Onward"

    String c = "*" + getResources().getString(R.string.rupee) + str_pay_at_store;
    SpannableString spannable2 = new SpannableString(c);
    spannable2.setSpan(new ForegroundColorSpan(Color.RED), 0, 1, 
    Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
    tv_payatstore.setText(spannable2);
    

    You can see like this

提交回复
热议问题