I mean something like:
Error!
You can change text color through
string.xml
:
Completed / Running / Not Alloted
If you want to set text programatically then you can use it it will render your text color dynamically.
private SpannableStringBuilder setSpan(int completed, int running){
SpannableStringBuilder span1 = new SpannableStringBuilder(completed+" / ");
ForegroundColorSpan color1=new ForegroundColorSpan(Color.parseColor("#6DC287"));
span1.setSpan(color1, 0, span1.length(), Spannable.SPAN_INCLUSIVE_INCLUSIVE);
SpannableStringBuilder span2 = new SpannableStringBuilder(running+"");
ForegroundColorSpan color2=new ForegroundColorSpan(Color.parseColor("#FFCC29"));
span2.setSpan(color2, 0, span2.length(), Spannable.SPAN_INCLUSIVE_INCLUSIVE);
Spanned concatenated=(Spanned) TextUtils.concat(span1, span2);
return new SpannableStringBuilder(concatenated);
}