我需要为整个应用程序设置背景颜色。在xml中,我们在片段或活动中使用
Compose有什么类似的功能?Surface参数和theme colorPalette无法帮助。请寻找解决方案。
android:background
标签。Compose有什么类似的功能?Surface参数和theme colorPalette无法帮助。请寻找解决方案。
android:background
标签。您可以将您的应用程序放置在一个带有所需背景的Box
内:
setContent {
YourTheme {
Box(
modifier = Modifier
.fillMaxSize()
.background(Color.Yellow)
) {
YourApp()
}
}
}
YourApp
中定义(例如使用Jetpack Navigation),那么它将为所有屏幕应用颜色。 - Phil Dukhov<style name="Theme.YourThemeName"
parent="Theme.MaterialComponents.DayNight.DarkActionBar">
...
<item name="android:windowBackground">@color/purple_700</item>
</style>
lightColorScheme
的background
。 - user924