英文:
CircularProgressIndicator: Can't resize properly
问题
我的代码:
Row (
modifier = Modifier.fillMaxWidth().padding(16.dp),
verticalAlignment = Alignment.CenterVertically
) {
Checkbox(
checked = checked,
enabled = habit.enabled,
onCheckedChange = { checked = !checked },
modifier = Modifier.size(23.dp).padding(end = 8.dp)
)
CircularProgressIndicator(
progress = animatedProgress,
modifier = Modifier.size(23.dp).padding(end = 8.dp)
)
Icon(
imageVector = habit.icon,
contentDescription = null,
modifier = Modifier.padding(end = 8.dp)
)
Text(
text = LocalContext.current.getString(habit.stringResourceId),
maxLines = 1
)
}
这是它的输出:
我希望它与复选框和图标的大小相同,但由于某种原因它没有达到这个效果。
英文:
My code:
Row (
modifier = Modifier.fillMaxWidth().padding(16.dp),
verticalAlignment = Alignment.CenterVertically
) {
Checkbox(
checked = checked,
enabled = habit.enabled,
onCheckedChange = { checked = !checked },
modifier = Modifier.size(23.dp).padding(end = 8.dp)
)
CircularProgressIndicator(
progress = animatedProgress,
modifier = Modifier.size(23.dp).padding(end = 8.dp)
)
Icon(
imageVector = habit.icon,
contentDescription = null,
modifier = Modifier.padding(end = 8.dp)
)
Text(
text = LocalContext.current.getString(habit.stringResourceId),
maxLines = 1
)
}
Here's what it outputs:
I want it to be the same size as checkbox and icon, but it does that for some reason.
答案1
得分: 1
请注意,我将为您提供代码的翻译,但是我无法显示图片。以下是您提供的代码的翻译:
将Row的每个项目使用Box布局包装,使用以下代码片段。
@Preview(showBackground = true)
@Composable
fun Test() {
Row(
modifier = Modifier
.fillMaxWidth()
.padding(16.dp),
verticalAlignment = Alignment.CenterVertically
) {
val modifier = Modifier
.padding(end = 8.dp)
Box(
modifier = modifier,
) {
Checkbox(
checked = true,
enabled = true,
onCheckedChange = {},
modifier = Modifier.size(23.dp)
)
}
Box(
modifier = modifier,
) {
CircularProgressIndicator(
progress = 0.9f,
strokeWidth = 2.dp,
modifier = Modifier.size(23.dp)
)
}
Box(
modifier = modifier,
) {
Icon(
imageVector = Icons.Default.Info,
contentDescription = null,
modifier = Modifier
.size(23.dp)
)
}
Text(
text = "Some Text Goes Here",
maxLines = 1
)
}
}
上述代码片段将产生以下结果。
英文:
Wrap each item of Row with Box layout, Use below code snippet.
@Preview(showBackground = true)
@Composable
fun Test() {
Row(
modifier = Modifier
.fillMaxWidth()
.padding(16.dp),
verticalAlignment = Alignment.CenterVertically
) {
val modifier = Modifier
.padding(end = 8.dp)
Box(
modifier = modifier,
) {
Checkbox(
checked = true,
enabled = true,
onCheckedChange = {},
modifier = Modifier.size(23.dp)
)
}
Box(
modifier = modifier,
) {
CircularProgressIndicator(
progress = 0.9f,
strokeWidth = 2.dp,
modifier = Modifier.size(23.dp)
)
}
Box(
modifier = modifier,
) {
Icon(
imageVector = Icons.Default.Info,
contentDescription = null,
modifier = Modifier
.size(23.dp)
)
}
Text(
text = "Some Text Goes Here",
maxLines = 1
)
}
}
This above code snippet will yield result like this.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论