英文:
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论