为什么 Jetpack Compose 卡半径角不均匀
Why is the Jetpack Compose card radius corner not even
我有一个 lazyColumn
包装
的项目
@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
)
}
}
看起来顶部和底部的角的圆度不同。我做错了什么吗?
您的卡片高度太小,无法正确显示形状。它应该至少是你半径的两倍
Card(
modifier = Modifier.preferredHeight(100.dp),
shape = RoundedCornerShape(50.dp),
backgroundColor = Color(0xFFFF0000),
)
或以百分比形式设置形状的半径:
Card(
shape = RoundedCornerShape(50),
backgroundColor = Color(0xFFFF0000),
)
我有一个 lazyColumn
包装
@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
)
}
}
看起来顶部和底部的角的圆度不同。我做错了什么吗?
您的卡片高度太小,无法正确显示形状。它应该至少是你半径的两倍
Card(
modifier = Modifier.preferredHeight(100.dp),
shape = RoundedCornerShape(50.dp),
backgroundColor = Color(0xFFFF0000),
)
或以百分比形式设置形状的半径:
Card(
shape = RoundedCornerShape(50),
backgroundColor = Color(0xFFFF0000),
)