You can do a lot of things in a single line of string.
1 and 3 represent the starting and ending positions of the set font.
private void SetText ()
{
Spannablestringbuilder style=new Spannablestringbuilder ("Welcome to Golden Sun");
Style.setspan (New Foregroundcolorspan (Getresources () GetColor (R.color.blue)),4,6, spannable.span_exclusive_exclusive);
Style.setspan (New Foregroundcolorspan (Getresources () GetColor (r.color.red)),1,3, spannable.span_exclusive_exclusive);//Set Font color
Style.setspan (New Stylespan (Typeface.bold),1,3, spannable.span_exclusive_exclusive); Set Font weight
Style.setspan (New Absolutesizespan (30,true),1,3, spannable.span_exclusive_exclusive); Set Font size
Characterstyle span=new Underlinespan ();
Style.setspan (span,1,3, spannable.span_exclusive_exclusive);//Set Underline
Style.setspan (NewStrikethroughspan (),1, 3, spanned.span_exclusive_exclusive); Delete Line
Textview1.settext (style);
}
:
Reference: http://blog.csdn.net/moyunfei1987/article/details/11646835
http://blog.csdn.net/u013493809/article/details/27683415
http://blog.csdn.net/meihua1314/article/details/40986643
Spannablestringbuilder of Android character settings