Reputation: 659
I want to create a Text view in which I want some characters to be of 40pt size and some characters to be of 20pt.
I tried using Html.fromhtml() but can't find any tag for changing size as such..
pleas help if this Is possible.
Upvotes: 3
Views: 2107
Reputation: 4400
You can use html for this.
for eg. A A A
String abc="<font color=BLUE><i>A</i></font>";
abc=abc+"<b>A</b><i>A</i>";
textView.setText(Html.formHtml(abc));
You can set Any size of the text using the font tag and also set it's color..
This is the easiest way to do this;
Upvotes: 1
Reputation: 24031
Use SpannableStringBuilder like this:
SpannableStringBuilder spanTxt = new SpannableStringBuilder("Different");
spanTxt.append(" android.");
//make the textsize 2 times.
spanTxt.setSpan(new RelativeSizeSpan(2f), spanTxt.length() - " android".length(), spanTxt.length(), 0 );
Upvotes: 12