Solution 1 :
Your applcation theme should inherit from DynamicColors like this:
values/themes.xml
<style name="Theme.App" parent="Theme.Material3.DynamicColors.Light">
</style>
Dark theme:
values-night/themes.xml
<style name="Theme.App" parent="Theme.Material3.DynamicColors.Dark">
</style>
Do not define colors like for example “colorPrimary” or “colorSurface” inside your Theme.App style.
Reference the created theme in your Manifest:
<application
....
android_theme="@style/Theme.App">
Problem :
I created a new Android app in Android Studio and selected a simple project template and Kotlin as the language. The app that’s generated has a purple toolbar and purple buttons. I know where those colors are defined (in the different color definitions in the project’s themes.xml
file) but I want the app to just use the default themes (light and dark) currently defined on the device.
How do I disconnect the custom theme and just let the app use the defaults for the device. My device’s running Android 12, so the current theme could be dynamic.
Comments
Comment posted by johnwargo
That doesn’t solve my problem, I don’t want to have any custom colors or theme defined. My question is about how do I ONLY use the device themes in my app.
Comment posted by Philipp Schumann
Do not define custom colors. This theme uses the colors of your wallpaper on Android 12
Comment posted by johnwargo
so do what? delete the styles.xml file? Delete the color definitions somewhere? I’m trying to understand what to do to fix this
Comment posted by Philipp Schumann
I edited the answer so it is more straight forward what to do. You can leave your styles.xml as is. In general App themes should be defined in values/themes.xml and custom styles (e.g. a custom button style) should be defined in values/styles.xml.
Comment posted by johnwargo
Thanks. I tried it but can’t make it work. I’ll dig into this more tomorrow.