Reputation: 135
After using custom fonts, I can't get type face style (BOLD, ITALIC, BOLD_ITALIC) of a text view by :
textView.getTypeface.getStyle();
In fact setting new type face style doesn't apply to textView really, although we can see the style is changing visually. I set type face style like this:
Typeface font = Typeface.createFromAsset(getAssets(), "sampleFont.ttf");
textView.setTypeface(font, Typeface.BOLD);
But,
textView.getTypeface.getStyle();
returns 0 (NORMAL) instead of 1 (BOLD)! All these happen when I trying to use a regular font.
Upvotes: 1
Views: 826
Reputation: 10559
Typeface
also has the methods isBold()
and isItalic()
since API level 1.
Or try this
if(textView.getTypeface()!=null){
if(textView.getTypeface().getStyle()==Typeface.BOLD || textView.getTypeface().getStyle()==Typeface.ITALIC){
//your code goes here
}
}
Upvotes: 0