Reputation: 6927
In my layout, I have defined a TextView
and have given it the id - textName
.
Programmatically, I have set its text to My name is Blah
. I was wondering if it is possible to programmatically increase the textsize
of just Blah
and not the whole TextView
?
Upvotes: 1
Views: 197
Reputation: 1844
Or simply using the Spannable class:
String text = textView.getText();
Spannable span = new SpannableString(text);
span.setSpan(new RelativeSizeSpan(1.5f), text.indexOf("Blah"), text.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
textView.setText(span);
Upvotes: 4
Reputation: 2263
Yes!! you can do by formatting the string with HTML, refer https://stackoverflow.com/a/1533512/603233
like eg
String text = "<h5>My name is </h5><h1>Blah</h1>";
yourtextview.setText(Html.fromHtml(text));
Upvotes: 0