Properties of the Spannablestring:
1, Backgroundcolorspan background color
2, Clickablespan text can be clicked, there are click events
3. Foregroundcolorspan text color (foreground)
4, Maskfilterspan modification effect, such as Blur (Blurmaskfilter), Relief (Embossmaskfilter)
5, Metricaffectingspan parent class, generally do not use
6. Rasterizerspan Grating Effect
7. Strikethroughspan Strikethrough (middle dash)
8. Suggestionspan equals placeholder
9, Underlinespan underline
10, Absolutesizespan absolute size (text font)
11, Dynamicdrawablespan set the picture, based on the text baseline or bottom alignment.
12. Imagespan Pictures
13, Relativesizespan relative size (text font)
14, Replacementspan parent class, generally do not use
15. Scalexspan based on x-axis scaling
16. Stylespan font Style: bold, italic, etc.
17, Subscriptspan subscript (the mathematical formula will be used)
18, Superscriptspan superscript (mathematical formula will be used)
19. Textappearancespan text appearance (including font, size, style and color)
20. Typefacespan Text Font
21. Urlspan Text Hyperlink
Import Android.app.activity;import android.content.intent;import android.graphics.color;import android.os.Bundle; Import Android.text.spannablestring;import Android.text.spanned;import Android.text.method.LinkMovementMethod; Import Android.text.style.backgroundcolorspan;import Android.text.style.clickablespan;import Android.text.style.foregroundcolorspan;import Android.text.style.strikethroughspan;import Android.text.style.stylespan;import Android.text.style.typefacespan;import Android.text.style.urlspan;import Android.text.style.underlinespan;import Android.view.menu;import Android.view.menuitem;import Android.view.View; Import android.widget.textview;/* 1, backgroundcolorspan background color 2, Clickablespan text clickable, have click event 3, Foregroundcolorspan Text color (foreground color) 4, maskfilterspan adornment effect, such as Blur (Blurmaskfilter), Emboss (Embossmaskfilter) 5, Metricaffectingspan parent class, generally do not have 6, Rasterizerspan Raster Effect 7, Strikethroughspan strikethrough (in dash) 8, Suggestionspan equals placeholder 9, Underlinespan underscore 10, Absolutesizespan Absolute size (text font) 11, Dynamicdrawablespan set picture, based on text baseline or bottom alignment. 12, Imagespan picture 13, Relativesizespan relative size (text font) 14, Replacementspan parent class, generally not 15, Scalexspan based on x-axis scaling 16, Stylespan font style: bold, italic, etc. 17, Subscriptspan subscript (the mathematical formula will be used) 18, Superscriptspan superscript (mathematical formula will be used) 19, Textappearancespan text appearance (including font, size, style and color) 20, Typefacespan text Font 21, urlspan text Hyperlink */public class Mainactivity extends Activity {@Overrideprotected void onCreate (Bundle s Avedinstancestate) {super.oncreate (savedinstancestate); Setcontentview (R.layout.activity_main); TextView TextView1, textView2, Textview3;textview1 = (TextView) Findviewbyid (r.id.textview1); textView2 = (TextView) Findviewbyid (r.id.textview2); textView3 = (TextView) Findviewbyid (R.ID.TEXTVIEW3); String Text1, Text2, Text3; Spannablestring spannableString1, spannableString2, spannablestring3;text1 = "background color, font color"; text2 = "Baidu link, font style"; Text3 = " Delete line, underline, click event "; spannableString1 = new spannablestring (Text1); spannableString2 = new spannablestring (TEXT2); SpannableString3 = new spannablestring (TEXT3); Spannablestring1.setspan (new Backgroundcolorspan (Color).YELLOW), 0, 5,spanned.span_exclusive_exclusive); Spannablestring1.setspan (new Foregroundcolorspan (Color.RED), 5, 9, spanned.span_exclusive_inclusive); Spannablestring2.setspan (New Urlspan ("http://www.baidu.com"), 0, 4,spanned.span _exclusive_inclusive); Spannablestring2.setspan (new Stylespan (Android.graphics.Typeface.BOLD_ITALIC), 5, 9, spanned.span_exclusive_inclusive); Spannablestring3.setspan (new Strikethroughspan (), 0, 3,spanned.span_exclusive_ INCLUSIVE); Spannablestring3.setspan (new Underlinespan (), 5, 8,spanned.span_exclusive_inclusive); Spannablestring3.setspan (New Clickablespan () {@Overridepublic void OnClick (View widget) {//TODO auto-generated method Stubintent Intent = new Intent (Mainactivity.this,activity1.class); startactivity (intent);}}, 9, +, Spanned.span_ exclusive_inclusive); Textview1.settext (spannableString1); Textview2.settext (spannableString2); textview3.settext (SPANNABLESTRING3); Textview1.setmovementmethod (Linkmovementmethod.getinstance ()); Textview2.setmovementmethod ( LinkmoveMentmethod.getinstance ()); Textview3.setmovementmethod (Linkmovementmethod.getinstance ());}}
Android------spannablestring