Loading

Sunday, September 4, 2011

Set styling text on TextView

styling text





Define your string resource (stylingtext) in /res/values/strings.xml, with styling markup.


<?xml version="1.0" encoding="utf-8"?>

<resources>

<string name="hello">Hello World, AndroidStylingTextActivity!</string>

<string name="app_name">AndroidStylingText</string>

<string name="stylingtext">

Styling Text:\n

<i>Italic</i> <b>Bold</b> <monospace>Monospace</monospace>\n

<strike>Strike</strike> <sup>Superscript</sup> <sub>Subscript</sub> <u>Underline</u>\n

<big><big><big>Big x 3 </big>Big x 2 </big>Big</big> <small>Small <small>Small x 2</small></small>

</string>

</resources>










Then you can refer the string resource in your layout file, main.xml.


<?xml version="1.0" encoding="utf-8"?>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"

android:orientation="vertical"

android:layout_width="fill_parent"

android:layout_height="fill_parent"

>

<TextView

android:layout_width="fill_parent"

android:layout_height="wrap_content"

android:text="@string/hello"

/>

<TextView

android:layout_width="fill_parent"

android:layout_height="wrap_content"

android:text="@string/stylingtext"

/>

</LinearLayout>








SHARE TWEET

Thank you for reading this article Set styling text on TextView With URL http://x-tutorials.blogspot.com/2011/09/set-styling-text-on-textview.html. Also a time to read the other articles.

0 comments:

Write your comment for this article Set styling text on TextView above!