2011-05-11 20 views
11

以下是android:textStyle="italic"未應用的簡單xml片段。爲什麼textStyle斜體在Android佈局中不適用於襯線以外的其他字體?

如果我刪除android:textStyle="italic,文本將出現。

<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"/> 

在上述android:textStyle="italic"工作僅android:typeface="serif",如果更改字體到SANS,等寬或正常的android:text沒有顯示。

這是爲什麼?

回答

3

試圖通過字符串進行文本斜體文件,它是替代這可能幫助你

例如

<?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> 
+0

這是好想法,但如何設置動態變化的內容。 – N20084753 2013-01-09 06:59:54

+0

我有完全相同的問題:它在Eclipse預覽(斜體)上正確顯示,但不在我的Galaxy Tab 2設備上正確顯示。 – thomaus 2013-01-17 10:48:27

0

我不幫你,但設置的字體+風格時,我有同樣的問題代碼,但只能在某些三星設備上使用,因此可能是設備/製造商特定的。

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

italicSupported總是等於true(除等寬),但在幾個三星設備(銀河II,注8)文本不顯示爲斜體。 Nexus 7是好的,愛可視80是好的。

相關問題