Why is the Jetpack Compose card radius corner not even

0

I'm having a lazyColumn that wrap items of

@Composable
fun MySimpleListItem(
    itemViewState: String,
    itemClickedCallback: (() -> Unit)? = null,
) {
    Card(
        shape = RoundedCornerShape(50.dp),
        backgroundColor = Color(0xFFFF0000),
    ) {
        Text(
            text = itemViewState,
            modifier = Modifier.fillMaxWidth().padding(16.dp),
            style = TextStyle(fontSize = 32.sp),
            textAlign = TextAlign.Center
        )
    }
}

Looks like the corner at the top and bottom is rounded differently. Did I do anything wrong?

enter image description here

android-cardview
android-jetpack-compose
asked on Stack Overflow Dec 12, 2020 by Elye

1 Answer

1

Your cards height is too small to display the shape correctly. It should be at least twice as large as your radius

Card(
    modifier = Modifier.preferredHeight(100.dp),
    shape = RoundedCornerShape(50.dp),
    backgroundColor = Color(0xFFFF0000),
)

or set the radius of your shape in percent:

Card(
    shape = RoundedCornerShape(50),
    backgroundColor = Color(0xFFFF0000),
    )
answered on Stack Overflow Dec 12, 2020 by jns

User contributions licensed under CC BY-SA 3.0