gpt4 book ai didi

android - 有没有办法强制显示 Jetpack Compose 文本?

转载 作者:行者123 更新时间:2023-12-04 23:57:31 24 4
gpt4 key购买 nike

所以我一直在努力解决以下问题。我做到了这一点(约翰的例子):

What I achieved

但我想做的是强制小时总是直接显示在文本之后,如果文本太长 - 溢出文本。所以 Jane Doe 的示例是完美的,与 Jack Doe 的示例相同(但在 Jack 的示例中那都是虚拟文本)。

而且我真的不知道我做错了什么。

那是我写的那段代码:

Row(modifier = Modifier
.fillMaxWidth()
.padding(horizontal = 10.dp, vertical = 7.dp),
verticalAlignment = Alignment.CenterVertically
) {
Column {
Row(
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.SpaceBetween
) {
// there's another Row printing the name
}
Spacer(Modifier.height(5.dp))
Row(verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.Start) {
Row(modifier = Modifier.wrapContentWidth(), horizontalArrangement = Arrangement.Start) {
Text(
text = item.message,
style = MaterialTheme.typography.subtitle1,
maxLines = 1,
overflow = TextOverflow.Ellipsis
)
}
Row(verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.Start) {
Circle() // that's my function which just shows the circle
Text(
text = dateString,
style = MaterialTheme.typography.subtitle1,
maxLines = 1,
modifier = Modifier.padding(horizontal = 4.dp)
)
}
}
}
}

我将非常感谢任何形式的帮助。

最佳答案

是这样的吗?

@Preview(showBackground = true)
@Composable
fun Test() {
Column {
Message(message = "short message")
Message(message = "short")
Message(message = "very long message")
}
}

@Composable
fun Message(message: String) {
Text("John Doe")
Row(horizontalArrangement = Arrangement.SpaceBetween) {
Text(
message,
modifier = Modifier.weight(1F, fill = false),
overflow = TextOverflow.Ellipsis,
maxLines = 1,
)
Text("8:35PM")
}
}

enter image description here

关于android - 有没有办法强制显示 Jetpack Compose 文本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68146769/

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