I recently migrated from xml to jetpack compose. Before I was using the Theme.MaterialComponents.Light.NoActionBar
theme. But now that I am using compose, the IDE does not recognize it when I try to change the parent style from my themes.xml file.
I did some research on the internet but didn't find anything that helps me much.
thank you for your help
First thing you should know about Jetpack Compose is that it's independent of XML, which means it does not rely AT ALL on XML themes and whatnot. Those parent layouts that you see in XML belong to the Material Components artifact and not the Jetpack Compose Material ones...
In other words, if you remove this dependency...:
implementation("com.google.android.material:material")
...you won't be able to use any of the "parent" themes because they only belong to the standard material library and not the Compose artifacts.
What do you do in this case ? if you still wanna use the parent themes in XML then you should keep the dependency, otherwise, if you want to shift and migrate completely into Jetpack Compose (Whether it's M2 or Material 3 You), then you need to consider applying your themes differently.
In general, Jetpack Compose is independent of XML, so in order to apply a theme, you need to wrap your composables inside a theme composable, you can generate a theme quickly here: Material Design theme builder, then, you can add the generated Kotlin files to your project (Yes, Jetpack compose themes are Kotlin files).
Last but not least, to apply the theme from the files you just imported, wrap your whole composables inside the AppTheme
composable which is by default provided in the files. Like this :
setContent {
AppTheme() {
///your whole UI here, wrapped inside the theme
}
}