1

String = " This is SAMPLE"

I want to increase the size of the SAMPLE alone in String to highlight, but need to be in a single string, this is to set in TextView.

Thanks in Advance.

Gnanam R
  • 397
  • 1
  • 3
  • 14

5 Answers5

5
textView.setText(Html.fromHtml("This is <font color='#707070' size='20'>
            SAMPLE</font>"));
Raghu Nagaraju
  • 3,278
  • 1
  • 18
  • 25
4

Try this:

String str = "This is <b>SAMPLE</b>";
yourTextView.setText(Html.fromHtml(str), BufferType.SPANNABLE);

Moreover, you may decorate your string (str) with html tags to alter the looks.

Or to highlight a part of text without using html stuff, read this

Community
  • 1
  • 1
waqaslam
  • 67,549
  • 16
  • 165
  • 178
0

Use Html.fromHtml() in setText() of TextView. Supported Html Tags can be found here Html Tags Supported by TextView

Shaiful
  • 5,643
  • 5
  • 38
  • 41
0

I think this is possible if you pass the text as html with your highlighted part enclosed in html <bold> tag.

Shubhayu
  • 13,402
  • 5
  • 33
  • 30
  • Shubhayu - yes you are right, its just make difference. If you use font size tag you can highlight at your wishing size. – Gnanam R Apr 19 '12 at 11:08
0

You have two options:

1, Format your string in HTML and use HTML.from("Your text");

2, Use spannable. A complete guide can find link here

Trung Nguyen
  • 7,442
  • 2
  • 45
  • 87