TextViewset TexttextSpan

Once you've defined the strings as resources, you can set them directly on a view such as TextView in the XML layout definition for that TextView. Listing 3-8 shows an example where an HTML string is set as the text content of a TextView.

Listing 3-8. Using String Resources in XML

<TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:textAlign="center" android:text="@string/tagged_string"/>

TextView automatically realizes that this string is an HTML string, and honors its formatting accordingly. This is nice because you can quickly set attractive text in your views as part of the layout.

0 0

Post a comment