Home > Net >  Android | Kotlin: How do I automatically change the text color based on device theme?
Android | Kotlin: How do I automatically change the text color based on device theme?

Time:03-07

I get that this question has probably been asked many times but in this specific situation I'm using gradients for my background so I can't base on solid background color. How do you get the theme (light/dark mode) on the device and change the text color accordingly? For instance, my Emulator uses light mode so the text looks fine but when switching to my actual device (using dark mode), the text still stays the same color (black) while the background changes from light to dark.

CodePudding user response:

You would create a new values folder values-night where you would create a whole new theme for night and your regular values folder would be your light theme.

Set the theme name as the same as your theme you have in your values folder and it will switch automatically

  • Related