TextColor与TextColorPrimary对比TextColorSecondary [英] TextColor vs TextColorPrimary vs TextColorSecondary

查看:712
本文介绍了TextColor与TextColorPrimary对比TextColorSecondary的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

每个应用程序中的每个文本都包含哪些内容?

What do each of these encompass in terms of text throughout an app?

更具体地说,在我的应用程序中,主题更改中的每一个都会发生什么变化?我希望我的按钮文本与我的文本视图的颜色不同;是一个主要的,另一个是次要的?

More specifically, what would changing each of these in a theme change throughout my app? I'd like my buttons' texts to be a different color than my textviews; is one primary and the other secondary?

欢迎任何与这些条款相关的信息!

Any info related to these terms is appreciated!

推荐答案

TextColor只是用于将颜色设置为任何给定视图的文本的xml属性。

TextColor is just the xml attribute to set a color to the text of any given view.

TextColorPrimary是启用按钮和大文本视图的默认文本颜色。

TextColorPrimary is the default text color for enabled buttons and Large Textviews.

TextColorSecondary是中小文本视图的默认文本颜色。

TextColorSecondary is the default text color for Medium and Small Textviews.

忽略这一点,关于你想做什么,有更好的方法。您希望编辑style.xml,以便默认主题AppTheme(或您在清单中声明为主题的任何其他内容)包含必要的xml属性以自定义文本颜色。

Ignore this, as for what you want to do, there is a better way. You want to edit your style.xml such that the default theme AppTheme (or whatever else you have declared as your theme in your manifest) contains the necessary xml attributes to customize your text colors.

完成后,生成的AppTheme样式将如下所示。

The resulting AppTheme style will look like this when youre done.

<!-- 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文件中。

textColor will set the default color for all of your textviews. buttonStyle will reference a custom style that you want for all of your buttons. To make this work, add this style tag to your styles.xml file.

<style name="myDefaultButton">
    <item name="android:textColor">#hexColorForButtons</item>
    <!-- other stuff you want your buttons to inherit by default -->
</style>

这篇关于TextColor与TextColorPrimary对比TextColorSecondary的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆