android italic typeface

前端 未结 3 1129
无人及你
无人及你 2021-01-07 08:57

I try to display italic text in a textview. I use the method TypeFace.defaultFromstyle(TypeFace.ITALIC) but it doesn\'t work, the style of the text is not set to italic. I

相关标签:
3条回答
  • 2021-01-07 09:25

    This should be all:

       textView.setTypeface(null, Typeface.BOLD_ITALIC);
       textView.setTypeface(null, Typeface.BOLD);
       textView.setTypeface(null, Typeface.ITALIC);
    
    0 讨论(0)
  • 2021-01-07 09:28

    Use setTypeface(Typeface) from the Java code or android:textStyle from the XML layout. They should do the trick, if you want all your text to be italic.

    Edit: In that case, I would think that your font doesn't have italic style, by default. From the documentation of the setTypeface(Typeface) method:

    Sets the typeface and style in which the text should be displayed. Note that not all Typeface families actually have bold and italic variants, so you may need to use setTypeface(Typeface, int) to get the appearance that you actually want.

    Do you use custom font? Try

    mTextView.setTypeface(Typeface.defaultFromStyle(Typeface.ITALIC), Typeface.ITALIC)
    
    0 讨论(0)
  • 2021-01-07 09:38

    From the docs on TextView ...

    public void setTypeface (Typeface tf, int style) Since: API Level 1

    Sets the typeface and style in which the text should be displayed, and turns on the fake bold and italic bits in the Paint if the Typeface that you provided does not have all the bits in the style that you specified.

    0 讨论(0)
提交回复
热议问题