1
1

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.

Jetpack Composeで角を丸くする

Posted at

はじめに

Jetpack Composeで丸い角のViewを作成する際にハマりました。何度もハマっている気がするので個人的なメモとして書きます。

正解

順番が大切です。clipを先に書くこと。
backgroundを先に書いてしまうと角が丸くなりません。

view.kt
Box(modifier = Modifier
                    .clip(RoundedCornerShape(20))
                    .background(color = Color.Red)
                    ) {
                    Text(
                        modifier=Modifier.padding(10.dp),
                        color = Color.White,
                        text = "テスト"
                    )
                }

スクリーンショット 2022-10-05 15.00.58.png

1
1
2

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
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?