Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android: How to check if TextView is bold or italic programatically

I would like to know how to construct an if statement to check if a TextView is bold or italic. Please help. Thank you.

like image 899
SpencerChantler123 Avatar asked Aug 02 '13 08:08

SpencerChantler123


1 Answers

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

public Typeface getTypeface ()

returns:

the current typeface and style in which the text is being displayed.

if(yourTextViewInstance.getTypeface()!=null){
   if(yourTextViewInstance.getTypeface().getStyle()==Typeface.BOLD || yourTextViewInstance.getTypeface().getStyle()==Typeface.ITALIC){
      //do your stuff
   }
}
like image 146
Boris Mocialov Avatar answered Oct 13 '22 01:10

Boris Mocialov