Android中的默认字体特征是什么?

Sep*_*phy 34 fonts android default

我知道可以在TypeFace类中找到字体属性,但我找不到Android中写入的默认特征.我的意思是,如果我采取TextView并简单地做setText("Blabla"),我会得到什么?px的大小是多少?哪个字体?等等

Mar*_*ues 86

你可以在这里检查小部件的默认样式:android/res/values/styles.xml

然后,找到你到达的Textview

  <style name="Widget.TextView">    
     <item name="android:textAppearance">?android:attr/textAppearanceSmall</item>    
 </style>
Run Code Online (Sandbox Code Playgroud)

经过一番研究后,您会发现此外观在相同的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>
Run Code Online (Sandbox Code Playgroud)

哪里

<item name="textColorSecondary">@android:color/secondary_text_dark</item>
Run Code Online (Sandbox Code Playgroud)

这些颜色在/ res/color /中定义,请检查/res/color/secondary_text_dark.xml

android/res/values文件夹添加书签是必须的!

更新:我的旧链接坏了,请检查Github上的Android核心资源文件夹.感谢kreker的链接.

  • 怎么样这个https://github.com/android/platform_frameworks_base/tree/master/core/res/res? (4认同)

小智 10

对于较新的4.0 ICS等,Android设计页面显示了字体大小列表:

http://developer.android.com/design/style/typography.html

全部指定为'sp'单位

HTH