0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Jetpack Compose のダイアログの背景を透明にしたい

Posted at

概要

Dialog はデフォルトで半透明の灰色背景になっているので、これを透明したかった。

方法

以下のStackoverflow の記事によると以下のように setDimAmount(0f) をしてあげれば透明になると書いてある。

@Preview(device = "id:Nexus S")
@Composable
private fun Test() {
    Dialog(onDismissRequest = { }) {
        ((LocalView.current.parent as DialogWindowProvider).window).setDimAmount(0f)
        Box(modifier = Modifier.fillMaxSize()) {
            Text(
                text = "Okay!",
                color = Color.Cyan,
                modifier = Modifier.align(Alignment.Center)
            )
        }
    }
}

Preview

Preview は以下のようになる。全然透明になってない!!

mr-android_–GroupShotResultDialogView_kt__mr-android_streaming_main.png

実機で見る

実機では以下のようになる。透明になってる!

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?