![](/img/trans.png)
[英]Can I change the value of a component from a separate button in Compose Multiplatform?
[英]Compose Multiplatform: remove 'x' button in window title bar
我的 Compose Multiplatform 應用程序中有一個對話框,並且想要刪除 window 標題欄中的關閉按鈕。 如果可以,如何刪除此按鈕? 現在,我已經通過在 onCloseRequest 中使用空的 function 刪除了按鈕的行為。
可重現的示例(您可以看到 2 windows 即將出現。從頂部的 window 中,我想刪除標題欄中的“x”):
import androidx.compose.material.MaterialTheme
import androidx.compose.ui.Alignment
import androidx.compose.ui.unit.dp
import androidx.compose.ui.window.*
fun main() {
application {
Window(
onCloseRequest = ::exitApplication,
title = "Desktop",
//icon = BitmapPainter(image = imageBitmap),
state = rememberWindowState(
position = WindowPosition(Alignment.Center)
),
) {
MaterialTheme() {
// Dialog
Dialog(
state = rememberDialogState(
position = WindowPosition(Alignment.Center),
width = 550.dp,
height = 500.dp
),
title = "My Dialog",
onCloseRequest = {},
) {
// removed dialog content
}
}
}
}
}
感謝並隨時詢問任何其他信息:)
唯一的方法是完全刪除應用欄
Window(
//...
undecorated = true,
//...
)
undecorated - 禁用或啟用此 window 的裝飾。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.