TextColor与TextColorPrimary对比TextColorSecondary

raf*_*asq 12 java android themes textcolor

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

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

任何与这些条款相关的信息表示赞赏!

Tem*_*Dev 19

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

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

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

忽略这一点,至于你想做什么,有一个更好的方法.您希望编辑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>
Run Code Online (Sandbox Code Playgroud)

textColor将为所有文本视图设置默认颜色.buttonStyle将为所有按钮引用所需的自定义样式.要使其工作,请将此样式标记添加到styles.xml文件中.

<style name="myDefaultButton">
    <item name="android:textColor">#hexColorForButtons</item>
    <!-- other stuff you want your buttons to inherit by default -->
</style>
Run Code Online (Sandbox Code Playgroud)