gpt4 book ai didi

android - 如何在 Row.horizo​​ntalArrangement 中结合 Arrangement.spacedBy() 和 Arrangement.Center

转载 作者:行者123 更新时间:2023-12-04 23:47:01 33 4
gpt4 key购买 nike

可以合并Arrangement.spacedBy(16.dp)Arrangement.CenterRow.horizontalArrangement ?
我想做的是将内容水平居中并设置默认间距16.dp .
我知道我可以结合 RowBox达到相同的结果,但我想知道是否可以只用他 Row的属性。

    Row(
modifier = Modifier.fillMaxWidth(),
horizontalArrangement = Arrangement.Center, // I would like to add the .spacedBy(16.dp), keeping the Center arrangement
verticalAlignment = Alignment.CenterVertically,
) {
Text(
text = stringResource(R.string.generic_error_pagination),
style = MaterialTheme.typography.subtitle1,
color = MaterialTheme.colors.textSecondary,
)
OutlinedButton(onClick = onClick) {
Text(stringResource(id = R.string.retry_button))
}
}

最佳答案

使用 spaceBy alignment 的变体范围:

An alignment can be specified to align the spaced children horizontally inside the parent

 Row(
modifier = Modifier.fillMaxWidth(),
horizontalArrangement = Arrangement.spacedBy(16.dp, Alignment.CenterHorizontally),
verticalAlignment = Alignment.CenterVertically,
)
enter image description here

关于android - 如何在 Row.horizo​​ntalArrangement 中结合 Arrangement.spacedBy() 和 Arrangement.Center,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71158345/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com