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

Vin*_*hwa 169 android textview android-xml

文档(或任何人)是否讨论了默认值的dpi值

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

SDK中的小部件?

大,中,小和常规文本视图

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

bie*_*eux 281

在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>
Run Code Online (Sandbox Code Playgroud)

\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>
Run Code Online (Sandbox Code Playgroud)

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

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


jfm*_*fmg 17

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

biegleux已经说过:

  • 代表14sp
  • 培养基代表18sp
  • 代表22sp

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

<dimen name="text_size_small">14sp</dimen>
<dimen name="text_size_medium">18sp</dimen>
<dimen name="text_size_large">22sp</dimen>
Run Code Online (Sandbox Code Playgroud)

以下是文件中包含文本的TextView的示例dimens.xml:

<TextView
  android:id="@+id/hello_world"
  android:text="hello world"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:textSize="@dimen/text_size_large"/>
Run Code Online (Sandbox Code Playgroud)


doc*_*ram 8

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

textView.setTextAppearance(android.R.style.TextAppearance_Large);
Run Code Online (Sandbox Code Playgroud)