简体   繁体   中英

Cannot set dark app theme Android Studio

I was trying to set dark background in theme like this -

    <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:colorBackground">@color/background_material_dark</item>
    <item name="android:textColorPrimary">@color/abc_primary_text_material_dark</item>
</style>

It is working on Android Lollipop, Marshmallow and Nougat, but on KitKat and older systems, the background is white. Could someone help me? (I want to keep ActionBar too)

What you're using is android:colorBackground , to change the Window Background you must also add android:windowBackground to the same value.

图片

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM