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. If i call the getStyle() method on the return of defaultFromstyle() it returns 0. Any idea ?
+1
A:
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)
Dimitar Dimitrov
2009-09-28 18:00:05
It's exactly what I do. Here is my code : myTextView.setTypeface(TypeFace.defaultFromstyle(TypeFace.ITALIC));but it doesn't work.Nb: if I use TypeFace.BOLD, all it's OK.
Arutha
2009-09-29 07:28:18
Yes ! It's works, but I don't understand why... I use custom font which sould have italic variant !
Arutha
2009-09-29 13:26:05