如何在 JetpackCompose 中设置脚手架抽屉宽度? [英] How to set the Scaffold Drawer Width in JetpackCompose?
本文介绍了如何在 JetpackCompose 中设置脚手架抽屉宽度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我们可以使用Scaffold
在JetpackCompose中使用Navigation Drawer,如下所示
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(
scaffoldState = scaffoldState,
drawerContent = { Text("Drawer content") },
drawerShape = customShape(),
content = {inner padding -> /* Body*/}
)
然后是您的 customShape 函数
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 */))
}
}
您也可以使用 Outline.Rounded 获得圆角
You can also use Outline.Rounded to get rounded corners
这篇关于如何在 JetpackCompose 中设置脚手架抽屉宽度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文