Styled Text introduces that Android Text supports HTML format. In this example, two methods are used to display the same string:
<String name = "styled_text"> Plain, <B> bold </B>, <I> italic </I>, <B> <I> bold-italic </I> </B> </string>
One is directly defined in R. layout. styled_text:
<TextView
Android: layout_width = "match_parent" android: layout_height = "wrap_content"
Android: gravity = "center_horizontal"
Android: textStyle = "normal"
Android: text = "@ string/styled_text"/>
Another method is to use the code method to access resources:
[Java]
CharSequence str = getText (R. string. styled_text );
TextView TV = (TextView) findViewById (R. id. text );
TV. setText (str );
CharSequence str = getText (R. string. styled_text );
TextView TV = (TextView) findViewById (R. id. text );
TV. setText (str );
Note that the Code uses CharSequence instead of the String type to maintain the Style definition of the text.
Author: mapdigit