如何在 Jetpack Compose "row" 或 "column" 中设置 ClipsToBounds "false"
How to set ClipToBounds "false" in JetpackCompose "row" or "column"
Row(modifier = Modifier.height(58.dp).fillMaxWidth().notClip()) {
Icon(
painter = painterResource(id = R.drawable.ic_launcher_foreground),
contentDescription = null,
modifier = Modifier
.height(100.dp)
.width(100.dp)
.clip(shape = CircleShape)
.clickable(
onClick = {
Toast
.makeText(
this@MainActivity,
"YOU clicked android button",
Toast.LENGTH_SHORT
)
.show();
},
))
}
在我上面的代码中,我试图在行约束之外显示按钮的涟漪 (就像在 github- 移动应用程序的底部导航栏中一样;当您单击bottomNavigation 栏它在 BottomNavigation 栏外显示波纹) 即 height(60.dp)
,但它不起作用。我研究了一下并创建了自己的扩展函数
fun Modifier.notClip()= graphicsLayer(clip = false) ;
并在 Row 的修饰符上使用它来禁用裁剪,但 Row 仍然裁剪要在 Row 的约束之外显示的波纹。有人帮忙!,
`
在 clickable
修饰符中,您可以指定 Indication
parameter. You can use the default ripple defined by rememberRipple
更改 bounded
参数。
Row(
modifier = Modifier.height(58.dp).fillMaxWidth().background(Color.Yellow)
) {
Icon(
painter = painterResource(id = R.drawable.ic_launcher_foreground),
contentDescription = null,
modifier = Modifier
.clickable(
interactionSource = interactionSource,
indication = rememberRipple(
//radius= 300.dp,
bounded = false),
onClick = { /* .. */ })
.height(100.dp)
.width(100.dp)
.clip(shape = CircleShape)
)
}
Row(modifier = Modifier.height(58.dp).fillMaxWidth().notClip()) {
Icon(
painter = painterResource(id = R.drawable.ic_launcher_foreground),
contentDescription = null,
modifier = Modifier
.height(100.dp)
.width(100.dp)
.clip(shape = CircleShape)
.clickable(
onClick = {
Toast
.makeText(
this@MainActivity,
"YOU clicked android button",
Toast.LENGTH_SHORT
)
.show();
},
))
}
在我上面的代码中,我试图在行约束之外显示按钮的涟漪 (就像在 github- 移动应用程序的底部导航栏中一样;当您单击bottomNavigation 栏它在 BottomNavigation 栏外显示波纹) 即 height(60.dp)
,但它不起作用。我研究了一下并创建了自己的扩展函数
fun Modifier.notClip()= graphicsLayer(clip = false) ;
并在 Row 的修饰符上使用它来禁用裁剪,但 Row 仍然裁剪要在 Row 的约束之外显示的波纹。有人帮忙!, `
在 clickable
修饰符中,您可以指定 Indication
parameter. You can use the default ripple defined by rememberRipple
更改 bounded
参数。
Row(
modifier = Modifier.height(58.dp).fillMaxWidth().background(Color.Yellow)
) {
Icon(
painter = painterResource(id = R.drawable.ic_launcher_foreground),
contentDescription = null,
modifier = Modifier
.clickable(
interactionSource = interactionSource,
indication = rememberRipple(
//radius= 300.dp,
bounded = false),
onClick = { /* .. */ })
.height(100.dp)
.width(100.dp)
.clip(shape = CircleShape)
)
}