开发者

Why textStyle italic is not applied in Android layout for other typefaces than serif?

Below is the simple xml snippet for which android:textStyle="italic" is not applying.

If I remove android:textStyle="italic the text will appear.

<TextView
    android:text="row one"
    android:textSize="15pt"
    android:typeface="serif"
    android:textStyle="italic"
    android:textColor="#00abcd"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_weight="1"/>

In the above android:textStyle="italic" is working only for android:typeface="serif", i开发者_开发百科f I change the typeface to sans, monospace or normal the android:text is not displaying.

Why is that?


try making text italic through strings file it is alternative to this might help you

example

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <string name="Row_one"><i>Row one</i></string>
    <string name="Row_two"><i>Row two</i></string>
</resources>


I does not help you, but I have the same problem when setting the Typeface + style in code, but only on certain Samsung devices so it could be device / manufacturer specific.

int supportedStyles = Typeface.create(TypeFace.DEFAULT, Typeface.BOLD_ITALIC).getStyle();
boolean italicSupported = (supportedStyles & Typeface.ITALIC) != 0;

italicSupported always equals true (except for Monospace) but on several Samsung devices (Galaxy II, Note 8) text is not displayed as italic. Nexus 7 is OK, Archos 80 is OK.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜