简体   繁体   English

在jetpack compose中看不到圆角

[英]Corner rounding not visible in jetpack compose

I am trying to do this as first time jetpack practice我正在尝试将其作为第一次喷气背包练习

Actually this is the code, the only thing missing is the rounded corners, I tried it and it does clip content, but it is not visible.实际上这是代码,唯一缺少的是圆角,我试过了,它确实剪辑了内容,但它不可见。

@Preview
@Composable()
fun Horizontal_card (){
Row(
    Modifier
        .size(width = 352.dp, height = 80.dp)
        .background(MaterialTheme.colors.background)
        .clip(RoundedCornerShape(10.dp)),
    verticalAlignment = Alignment.CenterVertically) {
    Spacer(Modifier.width(16.dp))
    Cardcontent ()
}

}

This is the preview of the component这是组件的预览

Order of Modifiers matter.修饰符的顺序很重要。 At the moment you set your background with在你设置背景的那一刻

fun Modifier.background(
    color: Color,
    shape: Shape = RectangleShape
) = this.then(
    Background(
        color = color,
        shape = shape,
        inspectorInfo = debugInspectorInfo {
            name = "background"
            value = color
            properties["color"] = color
            properties["shape"] = shape
        }
    )
)

which uses RectangleShape by default.默认情况下使用RectangleShape

You should either call你应该打电话

Modifier
    .size(width = 352.dp, height = 80.dp)
    .background(MaterialTheme.colors.background, RoundedCornerShape(10.dp))

or或者

Modifier
 .size(width = 352.dp, height = 80.dp)
 .clip(RoundedCornerShape(10.dp))
 .background(MaterialTheme.colors.background)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Jetpack ComposeleadingIcon 不可见 - Jetpack Compose leadingIcon not visible 最后一个元素在 LazyColumn 中不可见。 喷气背包组成 - The last elements are not visible in LazyColumn. Jetpack Compose 如何知道文本在 Jetpack Compose 上是否可见? - How to know if Text is visible on Jetpack Compose? Jetpack Compose Bottom Sheet 暗淡阴影不可见 - Jetpack Compose Bottom Sheet dim shadow not visible Android Jetpack compose:BackdropScaffold 背景与 GoogleMap 角落问题 - Android Jetpack compose: BackdropScaffold background with GoogleMap corner issue "如何在 Jetpack Compose Canvas 中绘制圆角多边形?" - How to draw rounded corner polygons in Jetpack Compose Canvas? 如何从jetpack compose中的可见地图获取LatLngBounds - How to get LatLngBounds from visible map in jetpack compose 是否存在与密码字段等效的 Jetpack Compose,用户可以看到密码? - Is there a Jetpack Compose equivalent of A password field with the password visible to the user? 在 jetpack compose LazyColumn 中获取最后一个可见项目索引 - Get last visible item index in jetpack compose LazyColumn 如果存在“Visible.Gone”元素,Jetpack Compose 测试将失败 - Jetpack Compose tests are failed if there is "Visible.Gone" element
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM