TextColor 与 TextColorPrimary 与 TextColorSecondary
TextColor vs TextColorPrimary vs TextColorSecondary
在整个应用中的文本中,每一项都包含什么?
更具体地说,更改主题中的每一项会在我的应用程序中发生什么变化?我希望按钮的文本颜色与文本视图的颜色不同;是一主一副?
如有任何与这些条款相关的信息,我们将不胜感激!
TextColor 只是 xml 属性,用于为任何给定视图的文本设置颜色。
TextColorPrimary 是启用按钮和大文本视图的默认文本颜色。
TextColorSecondary 是中型和小型 Textview 的默认文本颜色。
忽略这个,至于你想干什么,还有更好的办法。您想要编辑 style.xml 以便默认主题 AppTheme(或您在清单中声明为主题的任何其他内容)包含必要的 xml 属性以自定义文本颜色。
完成后生成的 AppTheme 样式将如下所示。
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="android:textColor">#hexColorForTextViews</item>
<item name="android:buttonStyle">@style/myDefaultButton</item>
</style>
textColor 将为所有文本视图设置默认颜色。 buttonStyle 将引用您想要的所有按钮的自定义样式。要使其正常工作,请将此样式标签添加到您的 styles.xml 文件中。
<style name="myDefaultButton">
<item name="android:textColor">#hexColorForButtons</item>
<!-- other stuff you want your buttons to inherit by default -->
</style>
在整个应用中的文本中,每一项都包含什么?
更具体地说,更改主题中的每一项会在我的应用程序中发生什么变化?我希望按钮的文本颜色与文本视图的颜色不同;是一主一副?
如有任何与这些条款相关的信息,我们将不胜感激!
TextColor 只是 xml 属性,用于为任何给定视图的文本设置颜色。
TextColorPrimary 是启用按钮和大文本视图的默认文本颜色。
TextColorSecondary 是中型和小型 Textview 的默认文本颜色。
忽略这个,至于你想干什么,还有更好的办法。您想要编辑 style.xml 以便默认主题 AppTheme(或您在清单中声明为主题的任何其他内容)包含必要的 xml 属性以自定义文本颜色。
完成后生成的 AppTheme 样式将如下所示。
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="android:textColor">#hexColorForTextViews</item>
<item name="android:buttonStyle">@style/myDefaultButton</item>
</style>
textColor 将为所有文本视图设置默认颜色。 buttonStyle 将引用您想要的所有按钮的自定义样式。要使其正常工作,请将此样式标签添加到您的 styles.xml 文件中。
<style name="myDefaultButton">
<item name="android:textColor">#hexColorForButtons</item>
<!-- other stuff you want your buttons to inherit by default -->
</style>