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) ;并在行的修饰符上使用它来禁用裁剪,但是行仍然会剪辑将显示在行约束之外的波纹。救命啊!
发布于 2021-05-07 13:28:26
在clickable修饰符中,可以指定参数。您可以使用定义的默认波纹来更改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)
)
}

https://stackoverflow.com/questions/67432928
复制相似问题