【问题标题】:How to draw draw behind the system status bar in a Jetpack Compose DialogHow to draw draw behind the system status bar in a Jetpack Compose Dialog
【发布时间】:2022-12-19 04:09:44
【问题描述】:

I disabled fitSystemWindows via WindowCompat.setDecorFitsSystemWindows(window, false) to draw behind the status bar and I am using the insets accompanist library to get the respective insets for adding padding to specific composables.

However, if I show a fullscreen dialog, the dialog still has padding to the system- and navigation bar and refuses to draw behind the status bar.

The Dialog looks like the following sn-p:

 Dialog(
       onDimissRequest = {},
        properties = DialogProperties(usePlatformDefaultWidth = false)
    ) {
    ..
    }

Is there any additional setting required in order to also let the dialog draw behind the system's status bar?

【问题讨论】:

  • What are you looking for exactly? You are displaying dialog and the status bar and navigation bars should appear on the top of the dialog?
  • Yes, or to be more specific: The dialog should be drawn below the status bar and the status bar itself should be transparent. That means the dialog takes the space of the whole screen and the Status bar is just on top of it.
  • I don't think it is possible because the dialog is supposed to be on the top all the components.
  • It's indeed possible with a legacy DialogFragment. I was hoping that Jetpack Compose would also offer a way to achieve that behavior.
  • Then why do you specifically want dialog? why not a full screen navigation screen or a new activity with the transparent status bar?

标签: android kotlin android-jetpack-compose android-dialogfragment android-dialog


【解决方案1】:

Maybe ModalDrawerLayout can help ?

ModalDrawerLayout(
    drawerContent = {
        // smth, idk
    },
    bodyContent = {
        Dialog(
            onDismissRequest = {},
            properties = DialogProperties(usePlatformDefaultWidth = false)
        ) {
            // Dialog content here
        }
    }
)

【讨论】:

    猜你喜欢
    • 2022-12-02
    • 2022-12-14
    • 2022-12-01
    • 2022-11-20
    • 2022-12-02
    • 2022-12-27
    • 2022-12-01
    • 2022-12-01
    • 2022-12-01
    相关资源
    最近更新 更多