0Pricing
Jetpack Compose Academy · レッスン

Background、Border、Clip

色、輪郭、角丸の形状を追加します。

「Background、Border、Clip」はCoddyKit上の無料Jetpack Compose Academyレッスンです。 これはレッスン2/4です。 下記で完全なレッスンを無料で読むことができます。その後、ブラウザ内の組み込みコードエディタと24時間対応のAIチューターでハンズオン演習できます。 これはJetpack Compose Academy学習パスの一部であり、ウェブとCoddyKitアプリ全体で進捗が同期されます。 Jetpack Compose Academyコースには全4レッスンが含まれています。

このレッスンの一部はまだ翻訳されておらず、英語で表示されています。

Decorate with Modifiers

Beyond sizing, modifiers can decorate a Composable. You can paint a background, draw a border, and round its corners. 🎨

Add a Background

background fills a Composable with a solid color. It paints the whole area the element occupies, including its size and fill.

Modifier.background(Color.Blue)

Use Theme Colors

Prefer theme colors over raw values. Pulling from MaterialTheme keeps your app consistent in light and dark mode.

Modifier.background(
  MaterialTheme.colorScheme.primary
)

Draw a Border

Use border to outline a Composable. Give it a thickness in dp and a color, and Compose draws the edge for you.

Modifier.border(2.dp, Color.Gray)

Meet Shapes

A Shape describes an outline like rounded or circular. Both background and border accept a shape to change their silhouette.

Rounded Corners

RoundedCornerShape softens corners by a radius in dp. It is the go-to shape for cards, buttons, and chips.

RoundedCornerShape(12.dp)

Shaped Background

Pass a shape to background and the color fills only inside that outline, giving you a tidy rounded panel.

Modifier.background(
  Color.LightGray,
  RoundedCornerShape(12.dp)
)

Clip the Content

clip trims anything drawn outside a shape. Use it so images and children respect your rounded corners.

Modifier.clip(RoundedCornerShape(12.dp))

Make a Circle

Reach for CircleShape when you want a perfect circle, like a round avatar or a floating button.

Modifier.clip(CircleShape)

Clip Before Drawing

Place clip before background so the fill is also rounded. Order in the chain decides what gets clipped.

Modifier
  .clip(RoundedCornerShape(12.dp))
  .background(Color.Cyan)

Combine for a Card

Stack clip, background, and border together to craft a polished card surface in just a few lines.

Modifier
  .clip(RoundedCornerShape(16.dp))
  .background(Color.White)
  .border(1.dp, Color.LightGray)

Quick Check

You want a rounded background where the fill itself is also rounded. Which modifier ensures that?

Recap

You can now style any element: background paints it, border outlines it, and clip with a Shape rounds it. 🎉

よくある質問

「Background、Border、Clip」レッスンは無料ですか?

はい。「Background、Border、Clip」の完全なテキストはこのウェブで無料で読めます。インタラクティブに演習し(組み込みコードエディタと24時間対応のAIチューター)、Jetpack Compose Academyコースの残りをアンロックするには、CoddyKit PROにアップグレードしてください。 Jetpack Compose Academyコースには全4レッスンが含まれています。

「Background、Border、Clip」で何を学びますか?

色、輪郭、角丸の形状を追加します。 ブラウザで直接実行するハンズオンコードでJetpack Compose Academyを演習し、24時間対応のAIチューターがレッスンを進める中での質問に答えます。

Jetpack Compose Academyを始めるのに経験は必要ですか?

事前経験は必要ありません。CoddyKitのJetpack Compose Academyは初級者から上級者向けに構成されているため、ここから始めるか最初から始めて、自分のペースで進むことができます。 これはレッスン2/4です。

「Background、Border、Clip」レッスンにはどのくらい時間がかかりますか?

ほとんどのCoddyKitレッスンは約5~10分かかります。各レッスンはコンパクトでインタラクティブなので、着実に進歩し、ウェブとアプリ全体で正確に前回の場所から再開できます。

このJetpack Compose Academyレッスンでコードを書いて実行できますか?

はい。すべてのJetpack Compose Academyレッスンに組み込みコードエディタが含まれているため、ブラウザでリアルコードを書いて実行し、即座のAIフィードバックを取得できます。ローカル設定は不要です。

このコースのすべてのレッスン

  1. Padding、Size、fillMaxWidth
  2. Background、Border、Clip
  3. Modifierの順序が重要な理由
  4. weightと柔軟なサイズ設定
← Jetpack Compose Academyに戻る