java - Custom sized italic Font using Spannable -


there following code:

string s = message + "\n" + date; spannable f = spannable.factory.getinstance().newspannable(s); f.setspan(new foregroundcolorspan(color.blue), 0, message.length(), 0); f.setspan(new foregroundcolorspan(color.red), message.length() + 1, s.length(), 0);  textview.settext(f); 

this code works fine setting diffent colors textview. need feature - i'd "date" has got smaller size of font , italic typeface. how can achieve that?

check this

different font size of strings in same textview

try below

string title="my custom text!";   textview tv = (textview) findviewbyid(r.id.some_id); spannablestring ss1=  new spannablestring(title); ss1.setspan(new stylespan(typeface.italic), 0, ss1.length(), 0); ss1.setspan(new relativesizespan(2f), 0, ss1.length, 0);  tv.settext(ss1); 

for more styling

http://www.chrisumbel.com/article/android_textview_rich_text_spannablestring


Comments

Popular posts from this blog

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

html - How to style widget with post count different than without post count -

url rewriting - How to redirect a http POST with urlrewritefilter -