受textColorPrimary影响的是什么以及如何控制它的副作用?

时间:2016-05-10 08:49:45

标签: android material-design

我有一个应用程序,我将colorPrimary设置为深蓝色。有了这个我用作AppBar的工具栏有一个深蓝色,因为我的主题基于Theme.AppCompat.Light.NoActionBar,默认情况下AppBar的文本(几乎)是黑色的。所以我按照我的风格将textColorPrimary设置为白色:

<item name="android:textColorPrimary">@color/text_primary_default</item>

但结果,现在我的导航抽屉中的文本也是白色的,以及带有textAppearanceLarge的TextViews,在(几乎)白色背景上。

如何正确解决此问题?我无法相信正确的方法是在导航视图中设置不同的样式(一个带有深textPrimaryColor的样式),所有文本视图以及受textPrimaryColor影响的任何其他样式。

1 个答案:

答案 0 :(得分:0)

改变navigationView中textview的颜色只能使用     的xmlns:应用程式=&#34; HTTP://schemas.android.com/apk/res-auto"

和着色以及stateColorList来定制它的未来

<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">

<!-- Other layout views -->

<android.support.design.widget.NavigationView
    android:id="@+id/nav_view"
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:layout_gravity="start"
    android:fitsSystemWindows="true"
    app:itemTextColor="#009688"
    app:headerLayout="@layout/nav_header"
    app:menu="@menu/drawer_view" />

文件参考here