默认“大”、“中”和“小”文本视图的 dpi 值 android
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11590538/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
dpi value of default "large", "medium" and "small" text views android
提问by Vinay W
Does the documentation ( or anyone) talks about the dpi values of the default
文档(或任何人)是否讨论了默认的 dpi 值
- Large TextView {
android:textAppearance="?android:attr/textAppearanceLarge"
} - Medium TextView {
android:textAppearance="?android:attr/textAppearanceMedium"
} - Small TextView {
android:textAppearance="?android:attr/textAppearanceSmall"
}
- 大文本视图 {
android:textAppearance="?android:attr/textAppearanceLarge"
} - 中等文本视图 {
android:textAppearance="?android:attr/textAppearanceMedium"
} - 小文本视图 {
android:textAppearance="?android:attr/textAppearanceSmall"
}
widgets in the SDK ?
SDK 中的小部件 ?
To put it in another way, can we replicate the appearance of these text views without using the android:textAppearance
attribute?
换句话说,我们可以在不使用android:textAppearance
属性的情况下复制这些文本视图的外观吗?
回答by biegleux
See in the android sdk directory.
在android sdk目录中查看。
In \platforms\android-X\data\res\values\themes.xml
:
在\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>
In \platforms\android-X\data\res\values\styles.xml
:
在\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
means style is inheriting from TextAppearance
style, you have to trace it also if you want to see full definition of a style.
TextAppearance.Large
意味着样式是从TextAppearance
样式继承的,如果您想查看样式的完整定义,还必须对其进行跟踪。
Link: http://developer.android.com/design/style/typography.html
链接:http: //developer.android.com/design/style/typography.html
回答by jfmg
To put it in another way, can we replicate the appearance of these text views without using the android:textAppearance attribute?
换句话说,我们可以在不使用 android:textAppearance 属性的情况下复制这些文本视图的外观吗?
Like biegleuxalready said:
就像biegleux已经说过:
- smallrepresents 14sp
- mediumrepresents 18sp
- largerepresents 22sp
- 小代表14sp
- 中代表18sp
- 大代表22sp
If you want to use the small, mediumor largevalue on any text in your Android app, you can just create a dimens.xml
file in your values
folder and define the text size there with the following 3 lines:
如果您想在 Android 应用程序中的任何文本上使用small、medium或large值,您只需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>
Here is an example for a TextView with largetext from the dimens.xml
file:
下面是一个带有来自文件的大文本的 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"/>
回答by doctorram
Programmatically, you could use:
以编程方式,您可以使用:
textView.setTextAppearance(android.R.style.TextAppearance_Large);