We can have Navigation Drawer in JetpackCompose by using Scaffold
as below
Scaffold(
drawerContent = { Text(text ="Drawer") }
) {}
I want to make the width of the drawer smaller. How can I do so?
Scaffold provides a slot for a floating action button. You can use the floatingActionButton slot and a FloatingActionButton : Scaffold( floatingActionButton = { FloatingActionButton(onClick = { /* ...
A LazyColumn is a vertically scrolling list that only composes and lays out the currently visible items. It's similar to a Recyclerview in the classic Android View system.
To change font size of Text composable in Android Jetpack Compose, pass a required font size value for the optional fontSize parameter of Text composable. Make sure to import sp , as shown in the above code snippet, when you are assign fontSize property with scale-independent pixels.
If you want to change the state of TextField and also update the UI, you can use a MutableState . Compose observes any reads and writes to the MutableState object and triggers a recomposition to update the UI.
You can modify the shape (including width and height) using drawerShape
parameter in Scaffold method.
So for instance
Scaffold(
scaffoldState = scaffoldState,
drawerContent = { Text("Drawer content") },
drawerShape = customShape(),
content = {inner padding -> /* Body*/}
)
Then your customShape function
fun customShape() = object : Shape {
override fun createOutline(
size: Size,
layoutDirection: LayoutDirection,
density: Density
): Outline {
return Outline.Rectangle(Rect(0f,0f,100f /* width */, 131f /* height */))
}
}
You can also use Outline.Rounded to get rounded corners
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With