简体   繁体   中英

how to properly create dark theme for android app?

I want to create a dark theme and have full control over which elements get which color. i defined a ``color(night) in value(night) resource and added some colors and changed themes(night) colors. but when i use colors. but when i use AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES); its seems that none of those defined colors are being used. the its seems that none of those defined colors are being used. the Action Bar``` is the same color as the background for some reason and none of the colors I defined in color resources are being used. I tried to define my own theme but everything got kind of messy.

what is the proper way to create a dark theme and define custom colors in it?

To use dark mode on your app You've got to create styles in night values. Your app's night theme style must extend Theme.AppCompat.DayNight.NoActionBar :

<style name="AppTheme" parent="Theme.AppCompat.DayNight.NoActionBar">
....

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