简体   繁体   English

使用 Android 和 Jetpack Compose 仅更改一个状态栏

[英]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.

相关问题 在 Jetpack Compose 中更改 android:windowBackground - Change android:windowBackground in Jetpack Compose Jetpack compose - 更改底部栏切口颜色 - Jetpack compose - change bottom bar cutout color SystemUIController 不会设置状态栏颜色 - Jetpack Compose Accompanist - SystemUIController won't set status bar color - Jetpack Compose Accompanist 在 jetpack compose 中更改状态栏颜色时遇到问题 - facing problem in changing status bar color in jetpack compose Jetpack Compose 状态栏颜色未在深色主题中更新 - Jetpack Compose status bar color not updated in Dark Theme 如何在 Jetpack Compose 对话框中绘制系统状态栏后面的绘图 - How to draw draw behind the system status bar in a Jetpack Compose Dialog Jetpack Compose 的状态栏中未显示模态底板稀松布颜色 - Modal Bottom Sheet scrim color is not shown in status bar in Jetpack compose Android Jetpack Compose - 背景颜色不会改变 - Android Jetpack Compose - Background color does not change Android Jetpack Compose 大小随时间变化的动画 - Android Jetpack Compose Animation of Size Change with Duration Android 使用 JetPack Compose 更改语言 - Android Language change using JetPack Compose
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM