1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

composeでSpannableを実装する

Posted at

初めに

今回は従来のSpannableをComposeで実装する方法を紹介していきます

本文

実装自体はとても単純で、compose自体に似たような機能が生えているのでそれを使うだけです

Text(
    text = buildAnnotatedString {
        append("hoge")
        withStyle(
            SpanStyle(
                color = R.color.red,
                fontWeight = FontWeight.Bold
            )
        ) {
            append("fuga")
        }
    }
)

上記のコードを書くとデフォルト表示でhogeが表示され、その後ろに赤色太字でfugaが表示されるようになります

最後に

今回は自分が実装していくのに調べたものを備忘録程度に残しておきました
どなたかの役に立てれば幸いです

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?