【问题标题】:Rounded corner only at top of image AysncImage Coil圆角仅在图像的顶部 AsyncImage Coil
【发布时间】:2023-02-03 07:50:01
【问题描述】:

我正在使用新的 AysncImage 加载程序在 Box 中进行组合。 Box 本身有一个 RoundedCornerShape。我还为具有以下值的 AsyncImage 添加了一个 RoundedCornerShape

Box(
            modifier = modifier

                .clip(RoundedCornerShape(16.dp))
        ) {
            AsyncImage(
                modifier = Modifier
                    .height(146.dp)
                    .clip(shape = RoundedCornerShape(
                        topStart = 16.dp,
                        topEnd = 16.dp,
                        bottomStart = 0.dp,
                        bottomEnd = 0.dp))
                ,
                model = R.drawable.image,
                contentDescription = null,
                contentScale = ContentScale.Crop,
            )
        }

但是图像的各个角落都是圆形的。 Screen Shot here

我不希望图像底部有圆角。

【问题讨论】:

  • 为什么你的外箱上有clip(RoundedCornerShape(16.dp))?这不是要在每个角落剪掉你的AsyncImage,不管你给你的AsyncImage 加上什么修饰符吗?
  • 正如#ianhanniballake 所说,只需删除 AsyncImage(...) 修饰符上的剪辑,因为框会自动剪辑您的图像
  • @ianhanniballake 移除了盒子夹,它做了我想要的,谢谢

标签: android android-jetpack-compose android-jetpack coil


【解决方案1】:

将此修改器添加到您的 AsyncImage

 modifier = Modifier.clip(RoundedCornerShape(topEnd = 8.dp , topStart = 8.dp))

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-05-06
    • 2011-11-09
    • 1970-01-01
    • 2019-09-21
    • 2016-03-30
    • 2012-01-27
    • 2012-02-14
    • 2019-04-07
    相关资源
    最近更新 更多