android-jetpack-compose - 使用 ModalBottomSheetLayout 时,如何在 Jetpack compose 中使背景和状态栏透明
问题描述
我是喷气背包的新手。我的应用在 MainScreen 中有 ModalBottomSheetLayout。现在,当我单击 MainScreen 的按钮时,它会显示 BottomSheet。当底部工作表打开时,背景是透明的,但状态栏不是。如何让它透明?
解决方案
至此,可以使用System UI Controller中的accompanist library
来控制 statusBar Color 和 navigationBar 颜色
implementation "com.google.accompanist:accompanist-systemuicontroller:0.18.0"
// 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
)
// setStatusBarsColor() and setNavigationBarsColor() also exist
}
推荐阅读
- c++ - 当没有异常时,我应该为每个函数添加 noexcept 吗?
- node.js - 启动不和谐机器人时出现此错误
- php - gcloud PHP没有连接到sql
- python - Python selenium无法通过xpath找到whatsapp web textarea
- python - Python数据框检测语言并翻译
- asp.net-core - 不使用@Localizer 的视图本地化
- c++ - 通过引用访问向量元素是否会降低 C++ 中的空间复杂度?
- python - Python无法识别for循环下的变量
- r - 你如何编写循环遍历和操作一列中具有相同值的行(例如名称)的 R 代码?
- javascript - 有没有办法在不刷新页面的情况下调用 django 函数