关于最新支持设计库的Day night theme

Regarding the Day night theme of latest support design library

我刚刚尝试使用新的主题样式 (Theme.AppCompat.DayNight),它可以工作,但弄乱了我的卡片背景。

如何更改卡片背景?

这是我的 v21/styles.xml

<resources>

<style name="AppTheme" parent="Theme.AppCompat.DayNight.NoActionBar">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/primary</item>
    <item name="android:colorPrimaryDark">@android:color/transparent</item>
    <item name="colorAccent">@color/accent</item>
    <item name="android:windowActionBar">false</item>

</style>

<style name="AppTheme.NoActionBar">
    <item name="windowActionBar">false</item>
    <item name="windowNoTitle">true</item>

    <item name="android:windowDrawsSystemBarBackgrounds">true</item>
    <item name="android:statusBarColor">@android:color/transparent</item>
</style>

还有我的 colors.xml 价值之夜限定词

<resources>
   <color name="primary">#ff01dc53</color>
   <color name="primaryDark">#ff01dc53</color>
   <color name="accent">#01dc53</color>

</resources>

我的应用程序 class :

    package com.cyanogen.unofficial.dashboard.util;

import android.app.Application;
import android.app.UiModeManager;
import android.content.Context;
import android.support.v7.app.AppCompatDelegate;

/**
 * Created by Shiva on 14-03-2016.
 */
public class MyApplication extends Application {

    static {

        AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_AUTO);


    }

    @Override
    public void onCreate() {
        super.onCreate();
        AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_AUTO);
        }
}

截图:

根据 release notes of the revision 23.2.1 of the Support Library, this version fixed issue 194497,为 CardView 添加深色主题。这是通过使用 CardView.Dark 样式来完成的。

所以你会在你的values/styles.xml中声明:

<style name="CardView.DayNight" parent="CardView.Light />

在你的 values-night/styles.xml 中:

<style name="CardView.DayNight" parent="CardView.Dark" />

然后将它应用到每个 CardViewstyle="@style/CardView.DayNight"