Moh*_*qer 5 android android-jetpack-compose
如何在 jetpack compose 中剪切如下图所示的可组合Text项Button?
ngl*_*ber 11
您可以使用drawWithContent修饰符。
Button(
onClick = {},
modifier = Modifier.drawWithContent {
if (layoutDirection == LayoutDirection.Rtl) {
clipRect(left = size.width / 2f) {
this@drawWithContent.drawContent()
}
} else {
clipRect(right = size.width / 2f) {
this@drawWithContent.drawContent()
}
}
}
) {
Text("some text")
}
Run Code Online (Sandbox Code Playgroud)
注意到我添加了对 RTL 语言的支持,从而切断了组件的左侧。
| 归档时间: |
|
| 查看次数: |
1910 次 |
| 最近记录: |