2010-11-26 56 views
33

我知道可以在TypeFace類中找到字體屬性,但我無法找到Android中寫入的默認特徵。我的意思是,如果我採取TextView並簡單地做setText("Blabla")就可以了,我會得到什麼? px中的大小?哪種字體?等Android中的默認字體特徵是什麼?

回答

86

你可以在這裏查看小工具的默認樣式:android/res/values/styles.xml

然後,找你的TextView達到

<style name="Widget.TextView">  
    <item name="android:textAppearance">?android:attr/textAppearanceSmall</item>  
</style> 

和研究一點點後,你會發現,這個外表在相同的styles.xml文件

<style name="TextAppearance.Small">  
<item name="android:textSize">14sp</item>  
<item name="android:textStyle">normal</item>  
<item name="android:textColor">?textColorSecondary</item>  
</style> 

其中

定義0
<item name="textColorSecondary">@android:color/secondary_text_dark</item> 

這些顏色在/res/color/定義,請檢查/res/color/secondary_text_dark.xml

的書籤文件夾android/res/values是必須的!

更新:我的舊鏈接已損壞,請在Github上檢查Android core resources folder。感謝克雷克的鏈接。

+1

當系統樣式確實具有語義含義,您不應該依賴從平臺版本到平臺版本或從設備到設備的相同值。儘管如此,它仍然是一個非常有用的書籤。 :) – adamp 2010-11-26 17:01:07