Sunday, 15 July 2012

java - Changing the font of String -



java - Changing the font of String -

i trying alter font size of string displaying on textview. remember there 2 string displaying on same textview.i want different font size both string.

string name = shopsarraylist.get(position); string address = shopsaddress.get(position);

i tried done on both string,

tv.settext(name.touppercase() + "\r\n" + address); tv.setpadding(25, 15, 0, 0); tv.settextsize(25);

please help!!!

you can using spannablestring.

see example:

string str= "hello world"; spannablestring spannable= new spannablestring(str); spannable.setspan(new relativesizespan(1.5f), 0, 5, 0); //size spannable.setspan(new foregroundcolorspan(color.cyan), 0, 5, 0);//color textview txtview= (textview) findviewbyid(r.id.textview); txtview.settext(spannable);

hope helps.

java android

No comments:

Post a Comment