Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set typeface for textview programmatically? [duplicate]

I am using textview in my application. In that I need to change the typeface for the textview programmatically. In a button click function i need to change the textview typeface. If typeface is Normal means i need to convert to Bold(Vice versa). If anybody knows the answer means kindly share with me. Thanks.

like image 986
Arunraj Jeyaraj Avatar asked Jul 15 '13 13:07

Arunraj Jeyaraj


1 Answers

To make your textView bold programmatically do:

textView.setTypeface(null, Typeface.BOLD);

To set it back to normal do:

textView.setTypeface(null, Typeface.NORMAL);

To get the current typeface use getTypeface()

http://developer.android.com/reference/android/widget/TextView.html#getTypeface()

like image 177
Ken Wolf Avatar answered Oct 23 '22 22:10

Ken Wolf