【问题标题】:How to set ClipToBounds "false" in JetpackCompose "row" or "column"如何在 Jetpack Compose “行”或“列”中设置 ClipToBounds “false”
【发布时间】:2021-05-07 10:09:08
【问题描述】:
    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-mobile 应用程序的底部导航栏中一样;当您单击底部导航栏中的按钮时,它会在底部导航之外显示涟漪bar) height(60.dp),但是它不起作用。我研究了一下并创建了自己的扩展功能

fun Modifier.notClip()= graphicsLayer(clip = false) ;

并在 Row 的修改器上使用它来禁用剪辑,但 Row 仍会剪辑要在 Row 约束之外显示的波纹。有人帮忙!????????? `

【问题讨论】:

    标签: android android-layout android-jetpack android-jetpack-compose dagger-hilt


    【解决方案1】:

    clickable 修饰符中,您可以指定Indication 参数。您可以使用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)
    
            )
        }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2023-01-03
      • 2022-11-28
      • 1970-01-01
      • 2022-01-02
      • 2022-09-28
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多