[英]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.