[英]Jetpack Compose: How to modify the width of Drawer in ModalNavigationDrawer?
[英]ModalNavigationDrawer doesn't totally collapse in Jetpack Compose
這是產生這種奇怪行為的代碼:
ModalNavigationDrawer(
drawerState = drawerState,
drawerContent = {
Column(
modifier = Modifier.fillMaxSize()
) {
items.forEach { item ->
NavigationDrawerItem(
modifier = Modifier.padding(NavigationDrawerItemDefaults.ItemPadding),
icon = {
Icon(
imageVector = item.icon,
contentDescription = null
)
},
label = {
Text(
text = item.name
)
},
onClick = {},
selected = true
)
}
}
},
content = {
Scaffold(
topBar = {},
content = { padding ->
Box(
modifier = Modifier.fillMaxSize().padding(padding)
) {
Box(
modifier = Modifier.fillMaxSize(),
contentAlignment = Alignment.Center
) {
Text(
text = "Profile"
)
}
}
}
)
}
)
我在用着:
implementation "androidx.compose.material3:material3:1.0.0-alpha16"
在從1.0.0-alpha15
更新之前,這個確切的代碼工作得非常好。
如何解決這個問題?
如果您將抽屜內容放入 ModalDrawerSheet 它可能會有所幫助。
因此:
ModalNavigationDrawer(
drawerState = drawerState,
drawerContent = {
ModalDrawerSheet {
Column(
modifier = Modifier.fillMaxSize()
etc
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.