Ely*_*lye 5 android-jetpack-compose android-jetpack-compose-scaffold
我们可以在 JetpackCompose 中使用导航抽屉,Scaffold
如下所示
Scaffold(
drawerContent = { Text(text ="Drawer") }
) {}
Run Code Online (Sandbox Code Playgroud)
我想让抽屉的宽度变小。我怎么能这样做?
Kof*_*fi 12
您可以使用ScaffolddrawerShape
方法中的参数修改形状(包括宽度和高度)。
例如
Scaffold(
scaffoldState = scaffoldState,
drawerContent = { Text("Drawer content") },
drawerShape = customShape(),
content = {inner padding -> /* Body*/}
)
Run Code Online (Sandbox Code Playgroud)
然后你的 customShape 函数
fun customShape() = object : Shape {
override fun createOutline(
size: Size,
layoutDirection: LayoutDirection,
density: Density
): Outline {
return Outline.Rectangle(Rect(0f,0f,100f /* width */, 131f /* height */))
}
}
Run Code Online (Sandbox Code Playgroud)
您还可以使用Outline.Rounded来获得圆角
Cyr*_*ind -4
您是否尝试过在抽屉可组合项中添加修饰符?
像这样的东西:
Scaffold(drawerContent = {
Box(modifier = Modifier.fillMaxWidth(0.9f){
Text(text = "Drawer")
}
}) {}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
534 次 |
最近记录: |