Quantcast
Channel: Y.A.M の 雑記帳
Viewing all articles
Browse latest Browse all 415

InlineTextContent を使って Composable のテキスト中にアイコンを表示する

$
0
0
val id = "inlineContent" val inlineContent = mapOf( Pair( id, InlineTextContent( Placeholder( width = 1.em, height = 1.em, placeholderVerticalAlign = PlaceholderVerticalAlign.AboveBaseline ) ) { Icon(imageVector = Icons.Default.OpenInNew, contentDescription = null) } ) ) Text( text = buildAnnotatedString { append("open here") appendInlineContent(id, "[open in new]") }, inlineContent = inlineContent, fontSize = 24.sp, ) PlaceholderVerticalAlign で上下の位置を指定できる。中央揃えにするなら PlaceholderVerticalAlign.TextCenter がよさげ。

Viewing all articles
Browse latest Browse all 415

Trending Articles