Jetpack Compose Academy · レッスン

ContentScaleとトリミング

画像をきれいにフィット、塗りつぶし、トリミングします。

レッスン 3/413 ステップ

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

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

When Image and Box Disagree

Your image has its own aspect ratio, but your layout slot has another. ContentScale decides how the picture fits into that space.

The Aspect Ratio Problem

Force a wide photo into a square and it can stretch or squash. ContentScale gives you sane rules so pictures never look distorted by accident.

Crop Fills and Trims

The most common choice is ContentScale.Crop. It fills the whole slot and trims any overflow, so the frame is always full with no gaps.

Image(painter = p, contentDescription = null,
    contentScale = ContentScale.Crop)

Fit Shows Everything

ContentScale.Fit shrinks the image until it all fits inside the slot. Nothing is cut off, but you may see empty space on two sides.

FillBounds Can Distort

ContentScale.FillBounds stretches the image to fill both dimensions exactly. It guarantees no gaps but will warp the aspect ratio.

Width or Height Only

Need to fill just one axis? FillWidth and FillHeight scale to match that single dimension while keeping the ratio.

Inside Crops, None Does Not

Inside only shrinks when too big and never enlarges, while None draws at original size, cropping if it overflows.

Crop Needs a Bounded Size

Crop only has an effect when the Image has fixed bounds. Give it a size or fillMaxWidth with a height, or there is nothing to crop into.

Image(painter = p, contentDescription = null,
    modifier = Modifier.size(120.dp), contentScale = ContentScale.Crop)

Align Within the Frame

When Fit leaves empty space, the alignment argument decides where the image sits, such as Center or TopStart.

Image(painter = p, contentDescription = null, alignment = Alignment.TopCenter)

Crop for Thumbnails

Thumbnails and avatars almost always use Crop. It guarantees a clean, gap-free tile no matter the source photo dimensions.

Pick by Intent

Choose by what matters: use Fit when the whole image must be visible, and Crop when a full, edge-to-edge frame matters more.

Quick Check

You want an avatar tile that is always completely filled with no empty space. Which ContentScale fits best?

Recap: Scaling Images

You can now choose ContentScale wisely: Crop to fill, Fit to show all, and align the result. Next: clipping into shapes! 🔲

無料で開始

AI チューターと学ぶ Kotlin — 無料

ブラウザでリアルコードを書いて実行し、24/7 の AI チューターから瞬時にサポートを受け、ウェブまたはアプリで続きから学習できます。

コース
30
レッスン
120

よくある質問

「ContentScaleとトリミング」レッスンは無料ですか?

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

「ContentScaleとトリミング」で何を学びますか?

画像をきれいにフィット、塗りつぶし、トリミングします。 ブラウザで直接実行するハンズオンコードでJetpack Compose Academyを演習し、24時間対応のAIチューターがレッスンを進める中での質問に答えます。

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

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

「ContentScaleとトリミング」レッスンにはどのくらい時間がかかりますか?

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

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

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

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

  1. Image Composable
  2. IconでMaterial Iconsを使う
  3. ContentScaleとトリミング
  4. 画像をクリップして形を整える
← Jetpack Compose Academyに戻る