voidm () {//Create a Spannablestring objectSpannablestring MSP =NewSpannablestring ("Font test font size half twice times foreground background color normal bold italic bold italic underline strikethrough x1x2 phone mail website sms MMS map x Axis synthesis"); //set Font (DEFAULT,DEFAULT-BOLD,MONOSPACE,SERIF,SANS-SERIF)Msp.setspan (NewTypefacespan ("monospace"), 0, 2, spanned.span_exclusive_exclusive); Msp.setspan (NewTypefacespan ("serif"), 2, 4, spanned.span_exclusive_exclusive); //Set Font size (absolute value, in pixels)Msp.setspan (NewAbsolutesizespan (20), 4, 6, spanned.span_exclusive_exclusive); Msp.setspan (NewAbsolutesizespan (20,true), 6, 8, spanned.span_exclusive_exclusive);//The second parameter, Boolean dip, if true, indicates that the preceding font size is in dip, otherwise pixels, ditto. //Set the font size (relative value, units: pixels) parameter to indicate how many times the default font sizeMsp.setspan (NewRelativesizespan (0.5f), 8, spanned.span_exclusive_exclusive);//0.5f means half of the default font sizeMsp.setspan (NewRelativesizespan (2.0f), ten, spanned.span_exclusive_exclusive);//2.0f indicates twice times the default font size//set font foreground colorMsp.setspan (NewForegroundcolorspan (Color.magenta), N, spanned.span_exclusive_exclusive);//set foreground color to magenta//set the font background colorMsp.setspan (NewBackgroundcolorspan (Color.cyan), spanned.span_exclusive_exclusive);//set the background color to cyan//set font style normal, bold, italic, bold italicMsp.setspan (NewStylespan (Android.graphics.Typeface.NORMAL), spanned.span_exclusive_exclusive);//NormalMsp.setspan (NewStylespan (Android.graphics.Typeface.BOLD), spanned.span_exclusive_exclusive);//Bold BodyMsp.setspan (NewStylespan (Android.graphics.Typeface.ITALIC), (spanned.span_exclusive_exclusive);//Italic BodyMsp.setspan (NewStylespan (Android.graphics.Typeface.BOLD_ITALIC), spanned.span_exclusive_exclusive);//Bold Italic Body//Set UnderlineMsp.setspan (NewUnderlinespan (), 27, 30, spanned.span_exclusive_exclusive); //Set StrikethroughMsp.setspan (NewStrikethroughspan (), 30, 33, spanned.span_exclusive_exclusive); //set up and down labelsMsp.setspan (NewSubscriptspan (), spanned.span_exclusive_exclusive, (+);// SubscriptMsp.setspan (NewSuperscriptspan (), spanned.span_exclusive_exclusive, Notoginseng;//superscript//Hyperlink (need to add Setmovementmethod method additional response)Msp.setspan (NewUrlspan ("tel:4155551212"), Panax Notoginseng, spanned.span_exclusive_exclusive);//TelephoneMsp.setspan (NewUrlspan ("Mailto:[email protected]"), (a), in all, spanned.span_exclusive_exclusive);//MailMsp.setspan (NewUrlspan ("http://www.baidu.com"), (a), spanned.span_exclusive_exclusive);//NetworkMsp.setspan (NewUrlspan ("sms:4155551212"), (a), spanned.span_exclusive_exclusive);//SMS Using SMS: or Smsto:Msp.setspan (NewUrlspan ("mms:4155551212"), (a), spanned.span_exclusive_exclusive);//MMS using MMS: or Mmsto:Msp.setspan (NewUrlspan ("geo:38.899533,-77.036476"), spanned.span_exclusive_exclusive);//Map//Sets the font size (relative value, units: pixels) The number of times the default font width is represented by the parameterMsp.setspan (NewScalexspan (2.0f), (spanned.span_exclusive_exclusive);//2.0f means twice times the width of the default font, which is twice times the x-axis, and the height of the default font is unchanged.//Set BulletsMsp.setspan (NewBulletspan (Android.text.style.bulletspan.standard_gap_width,color.green), 0, spanned.span_exclusive_exclusive );//The first parameter represents the width of the bullet, and the second parameter is the color of the bulletTv_textview.settext (MSP); Tv_textview.setmovementmethod (Linkmovementmethod.getinstance ()); }
Add: Dynamically intercept the string to be changed
spannablestring SpanS = new Spannablestring (getString (r.string.backup_policy_msg,
GetString (R.string.app_name), getString (R.string.terms_title))
String terms = getString (r.string.terms_title);
int i = SpanS. toString (). IndexOf (terms);
int j=i+ terms.length ();
Spannablestring Decorative Strings