默认“大”,“中”和“小”文本视图android的dpi值

时间:2012-07-21 08:07:10

标签: android textview android-xml

文档(或任何人)是否谈论默认

的dpi值
  • 大TextView {android:textAppearance="?android:attr/textAppearanceLarge"}
  • 中等TextView {android:textAppearance="?android:attr/textAppearanceMedium"}
  • 小TextView {android:textAppearance="?android:attr/textAppearanceSmall"}
SDK中的

小部件?

The Large, medium, small and regular text views

换句话说,我们可以在不使用android:textAppearance属性的情况下复制这些文字视图的外观吗?

3 个答案:

答案 0 :(得分:279)

在android sdk目录中查看。

\platforms\android-X\data\res\values\themes.xml

    <item name="textAppearanceLarge">@android:style/TextAppearance.Large</item>
    <item name="textAppearanceMedium">@android:style/TextAppearance.Medium</item>
    <item name="textAppearanceSmall">@android:style/TextAppearance.Small</item>

\platforms\android-X\data\res\values\styles.xml

<style name="TextAppearance.Large">
    <item name="android:textSize">22sp</item>
</style>

<style name="TextAppearance.Medium">
    <item name="android:textSize">18sp</item>
</style>

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

TextAppearance.Large表示样式继承自TextAppearance样式,如果要查看样式的完整定义,还必须跟踪样式。

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

答案 1 :(得分:16)

  

换句话说,我们可以在不使用android:textAppearance属性的情况下复制这些文本视图的外观吗?

就像biegleux已经说过:

  • small 代表14sp
  • medium 代表18sp
  • large 代表22sp

如果您想在Android应用中的任何文字上使用中等值,您只需创建一个{ {1}}文件夹中的{1}}文件,并使用以下3行定义文本大小:

dimens.xml

以下是values文件中带有文本的TextView示例:

<dimen name="text_size_small">14sp</dimen>
<dimen name="text_size_medium">18sp</dimen>
<dimen name="text_size_large">22sp</dimen>

答案 2 :(得分:8)

以编程方式,您可以使用:

textView.setTextAppearance(android.R.style.TextAppearance_Large);