[英]Alternatives to ReplacementSpan in Jetpack Compose?
InlineTextContent可能正是您要找的。 它使用AnnotatedString
和占位符,并允许您在文本中插入 Composables:
val text = buildAnnotatedString {
appendInlineContent("chip1", "Acid")
}
val inlineContent = mapOf(
"chip1" to InlineTextContent(
Placeholder(
width = 1.em, // calculate text width
height = 1.em, // calculate text height
placeholderVerticalAlign = PlaceholderVerticalAlign.AboveBaseline
)
) {
// call chip composable
}
)
BasicText(text = text, inlineContent = inlineContent)
如果您希望与 Text 一起使用,InlineTextContent 可能会很有用。 但是在 Textfield 的情况下,似乎还没有实现。 查看在问题跟踪器中提交的以下功能请求。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.