I m trying to set background color text view to length of the text in that text view ,
if I use textView.SetBackground()
then it will set background color to whole textview , i dont want this , I want backgorund color only for Text of that Textview... Thanks in advance...
Asked
Active
Viewed 524 times
0
-
What? are you saying that font color? What is background color of text? – Pankaj Kumar Sep 03 '13 at 04:50
-
please be more clear else we need to flag – Nezam Sep 03 '13 at 04:51
-
http://stackoverflow.com/questions/15582900/android-textview-text-background-color i want something like this....Android TextView text background color – ADT Sep 03 '13 at 05:33
4 Answers
0
Set the TextView's layout_width to wrap_content, then the background will only be as lasrge as the content.

alex
- 6,359
- 1
- 23
- 21
0
use SpannableString class
here is example
String btnText = btn.getText();
SpannableString spannableSummary = new SpannableString(btnText);
spannableSummary.setSpan(new ForegroundColorSpan(0xff6083f0), 0, summary.length(), 0);
btn.setText(btnText);

erkasraim
- 11
- 2
0
You can use :
textView.setTextColor();
To set text colour for your text view.

Vipul Purohit
- 9,807
- 6
- 53
- 76
0
You can use
String text = "This is <font color='blue'>blue</font>. This is <font color='red'>red</font>.";
textView.setText(Html.fromHtml(text), TextView.BufferType.SPANNABLE);

Jahirul Islam Mamun
- 659
- 8
- 11