Vins
Vins

Reputation: 4119

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", if I change the typeface to sans, monospace or normal the android:text is not displaying.

Why is that?

Upvotes: 13

Views: 3584

Answers (2)

Gerrit Beuze
Gerrit Beuze

Reputation: 921

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.

Upvotes: 1

UMAR-MOBITSOLUTIONS
UMAR-MOBITSOLUTIONS

Reputation: 77984

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>

Upvotes: 4

Related Questions