I want to add the hamburger icon to the Appbar and open/close drawer using the icon.
How would I achieve this?
Scaffold(
drawerShape = RoundedCornerShape(topRight = 10.dp, bottomRight = 10.dp),
drawerElevation = 5.dp,
drawerContent = {
// Drawer
},
topBar = {
TopAppBar(
navigationIcon = {
Icon(
Icons.Default.Menu,
modifier = Modifier.clickable(onClick = {
// Open drawer => How?
})
)
},
modifier = Modifier
.fillMaxWidth()
.clip(RoundedCornerShape(bottomLeft = 10.dp, bottomRight = 10.dp)),
title = { Text(text = "Hello") }
)
},
) {}
Use
rememberScaffoldState()
to modify drawer state.Scaffold
Use
state.drawerState.open()
orstate.drawerState.close()
in anonClick
to open/close the drawer.Create an Icon for
navigationIcon
inTopAppBar
: