I have a text view. Text view is mandatory so I want * symbol on top of text view in red color.
TextView text = (TextView)findViewById(R.id.text);
String simple = "Enter your name ";
String colored = "*";
SpannableStringBuilder builder = new SpannableStringBuilder(simple+colored);
builder.setSpan(new ForegroundColorSpan(Color.RED), simple.lenth(), builder.length(),
Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
text.setText(builder);
One of the easiest way to achieve this by using following code in your strings.xml file and provide color in your color.xml file
<string name="user_name">UserName <font color='red'>*</font></string>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With