【问题标题】:while using ModalBottomSheetLayout, how to make background and status bar transparent in Jetpack compose使用 ModalBottomSheetLayout 时,如何在 Jetpack compose 中使背景和状态栏透明
【发布时间】:2021-09-21 12:23:59
【问题描述】:

我是喷气背包的新手。我的应用在 MainScreen 中有 ModalBottomSheetLayout。现在,当我单击 MainScreen 的按钮时,它会显示 BottomSheet。当底部工作表打开时,背景是透明的,但状态栏不是。如何让它透明?

【问题讨论】:

    标签: android-jetpack-compose bottom-sheet android-statusbar


    【解决方案1】:

    到目前为止,您可以使用accompanist library中的System UI Controller来控制statusBar颜色和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
    }
    

    【讨论】:

      猜你喜欢
      • 2022-11-28
      • 2022-11-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-10-24
      • 2022-11-22
      • 1970-01-01
      相关资源
      最近更新 更多