Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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

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.

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading