When you create a new project in Android Studio selecting the template Jetpack Compose Material3 you get a project which defines following in themes.xml:
<style name="Theme.ComposeMaterial3" parent="android:Theme.Material.Light.NoActionBar" />
-
Is this being used by the project at all since the Composables
reference Material3 styles? (ComposeMaterial3Theme) -
Why does this not set as parent "Theme.Material3…"?
2
Answers
In your app you can define more compose themes (for example in the
Theme.kt
file).To apply one of them you have to wrap your composables with the favorite theme.
For example:
About the theme defined in the xml, you can extend a M3 theme for example:
Theme.Material3.Light.NoActionBar
but the composables don’t use it. They use the compose theme.
The theme defined in the
themes.xml
is used in the material components library (and other small parts as status bars).Your theme is defined as:
The
MaterialTheme
is defined in the packageandroidx.compose.material3
Yes, it’s being used. The app itself can still use xml themes for things like the status bar colour, and the app icon. A good example project is https://github.com/android/compose-samples/tree/main/Jetchat. You can see how they achieve the "material you" styling for multiple android versions using the Material3 theme in that project.
That would be a question for the template designer. In my opinion, if you look at the volume of theme based configuration required in JetChat to achieve consistent theming across multiple Android versions, I can believe that the Compose Material3 template is trying to keep things a bit more simple to highlight the concepts of material 3 in Compose. (Absolutely no evidence to back that up though).