4 Dec 2017

HOW TO DISPLAY A TEXT BOLD IN A TEXTVIEW IN ANDROID



TextView bold text

TextView widget display text on android app. we can render a TextView to display text as bold or italic both programmatically by java file and syntactically by xml layout file. we also can bold TextView text syntactically by using string resource file.
this first android app demonstrate us how can we render TextView text bold, italic, normal and even underlined by declarative syntax.



The android:textStyle attribute allow us to set the text style to normal, bold or italic. we can combine this style by separated them using keyboard pipe | symbol. so if we want to render TextView text as bold and italic then we need to set the android:textStyle attribute value as android:textStyle="blod|italic". android:textStyle="normal|italic" value display text as italic, android:textStyle="bold" value display text only bold and android:textStyle="normal" value define TextView text appearance as normal.

This is very interesting that we can render a TextView's part of text as bold, italic or underlined by using string resource file. the string resource file allow us to declare a string resource which value contain html tags. so the final output show the stylish text on android app. strings.xml resource file exist under res/values folder.

In the following example code, we declare a string key value pair name stylish_text and its value. stylish_text key's value contain html tags those make part of text bold, italic and underlined. in the xml layout file we can assign the string resource as android:text="@string/stylish_text".

Best Regards,

IKE DECK Team, 

For more help or suggestion; 

Phone: +234703020582, +2349060387294, +2348173666094 
Visit our Website: www.ikedeck.com.ng 
Subscribe to our YouTube channel: Click here. 
Register for our free Newsletter: Click here. 
Follow us on Twitter: Click here. 
Join our Facebook Page: Click here. 
Or join our Facebook Group: Click here.

No comments:

Post a comment