【发布时间】:2011-05-16 04:10:55
【问题描述】:
我知道字体属性可以在TypeFace类中找到,但是我在Android中找不到默认的书写特征。我的意思是,如果我使用TextView 并简单地在其上执行setText("Blabla"),我会得到什么?以px为单位的大小?哪种字体?等等
【问题讨论】:
我知道字体属性可以在TypeFace类中找到,但是我在Android中找不到默认的书写特征。我的意思是,如果我使用TextView 并简单地在其上执行setText("Blabla"),我会得到什么?以px为单位的大小?哪种字体?等等
【问题讨论】:
您可以在此处查看小部件的默认样式: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>
在哪里
<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。感谢 kreker 提供的链接。
【讨论】:
对于较新的 4.0 ICS 等,有显示字体大小列表的 Android 设计页面:
http://developer.android.com/design/style/typography.html
全部指定为“sp”单位
HTH
【讨论】: