[英]Change just one status bar with Android and Jetpack Compose
I'm working on a project with Android and Jetpack Compose and I want to change the status bar color for just one view and the rest of them keeping with the assigned color.我正在使用 Android 和 Jetpack Compose 开展一个项目,我想仅更改一个视图的状态栏颜色,并且其中的 rest 与指定的颜色保持一致。
How can I do this with Jetpack Compose?如何使用 Jetpack Compose 做到这一点? Is there a way to have more than one color in the status bar?
有没有办法让状态栏中的颜色不止一种?
You can do it following the doc here .您可以按照此处的文档进行操作。 You can update the system bar colors like so:
您可以像这样更新系统栏 colors:
// Remember a SystemUiController
val systemUiController = rememberSystemUiController()
val useDarkIcons = MaterialTheme.colors.isLight
SideEffect {
// Update all of the system bar colors to be transparent, and use
// dark icons if we're in light theme
systemUiController.setSystemBarsColor(
color = Color.Transparent,
darkIcons = useDarkIcons
)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.