"Go" use of Textappearancespan in Android

Source: Internet
Author: User

Use of Textappearancespan in Android

Posted on April 17, 2011

How do you want to have rich style settings for your text in Word like in Android?

Textappearancespan can help you achieve this goal.

Here is an example:

//format "Hello"Spannablestringbuilder Builder=NewSpannablestringbuilder (); String str1="Hello"; Spannablestring SS1=Newspannablestring (str1);intlen=str1.length (); Ss1.setspan (NewTextappearancespan (activity, Util.gettextappearanceresource (settings.theme,android). R.style.textappearance_large)),0, len,spanned.span_exclusive_exclusive);//set the world formatString str2="World";intLen2=str2.length (); Spannablestring SS2=Newspannablestring (STR2); Foregroundcolorspan ColSpan=NewForegroundcolorspan ((Context.getresources (). GetColor (r.color.red))); Ss2.setspan (ColSpan,0, Len2, spanned.span_exclusive_exclusive), Builder.append (SS1). Append (SS2). Append ("!"); Titleview.settext (builder);

Among them, "hello" constructs the style through the style textappearanceresource, "World" through the Foregroundcolorspan to set the text format.

This is the application of Textappearancespan, please leave a message.

Source Address: http://androidfuture.com/blog/?p=189

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.