Vin*_*hwa 169 android textview android-xml
文档(或任何人)是否讨论了默认值的dpi值
android:textAppearance="?android:attr/textAppearanceLarge"
}android:textAppearance="?android:attr/textAppearanceMedium"
}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已经说过:
如果您想在Android应用中的任何文本上使用小,中或大值,您只需dimens.xml
在values
文件夹中创建一个文件,并使用以下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)
以编程方式,您可以使用:
textView.setTextAppearance(android.R.style.TextAppearance_Large);
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
138584 次 |
最近记录: |