制約と固有サイズ測定
親と子の間でサイズを調整します。
「制約と固有サイズ測定」はCoddyKit上の無料Jetpack Compose Academyレッスンです。 これはレッスン3/4です。 下記で完全なレッスンを無料で読むことができます。その後、ブラウザ内の組み込みコードエディタと24時間対応のAIチューターでハンズオン演習できます。 これはJetpack Compose Academy学習パスの一部であり、ウェブとCoddyKitアプリ全体で進捗が同期されます。 Jetpack Compose Academyコースには全4レッスンが含まれています。
このレッスンの一部はまだ翻訳されておらず、英語で表示されています。
Constraints Are a Size Contract
A parent passes constraints to each child: the allowed min and max width and height. The child must choose a size that fits inside them. 📏
Four Numbers Define the Box
Every Constraints object holds minWidth, maxWidth, minHeight, and maxHeight. Together they describe the range of sizes a child may pick.
constraints.minWidth
constraints.maxWidth
constraints.maxHeightBounded vs Infinite Constraints
A max can be a real number or Infinity. Scrollable parents pass infinite height so children can be as tall as they need.
Loosen Constraints to Allow Smaller
Use copy to relax constraints before measuring. Setting minWidth to zero lets a child be smaller than the parent demands.
val loose = constraints.copy(minWidth = 0, minHeight = 0)Tighten Constraints to Force a Size
Set min equal to max and you force an exact size. The child has no choice but to be exactly that big.
val fixed = Constraints.fixed(width = 200, height = 100)Children Negotiate Within Bounds
Layout is a negotiation: the parent offers bounds, the child reports a size, the parent places it. Both sides shape the final result.
Why Intrinsics Exist
Sometimes a parent needs a child's size before the real measure pass. Intrinsic measurements answer that question without committing.
Min and Max Intrinsic Width
Ask minIntrinsicWidth for the smallest width that shows content without clipping, or maxIntrinsicWidth for the natural unwrapped width.
measurable.maxIntrinsicWidth(height)A Classic Use: Equal Heights
The built-in IntrinsicSize.Min modifier uses intrinsics to make a Row's children share the tallest height, like a divider matching its neighbors.
Row(Modifier.height(IntrinsicSize.Min)) { }Intrinsics Cost an Extra Query
Intrinsic queries run extra work, so use them only when needed. Most custom layouts get by with constraints alone. ⚡
Constraints Flow Down the Tree
Constraints cascade from the root down through every parent. Mastering how to tighten and loosen them is the heart of custom layout work.
Quick Check
How do you force a child to be an exact, fixed size?
Recap: Constraints & Intrinsics
Constraints set a child's allowed size range; loosen or tighten them with copy. Intrinsics peek at a size early, but cost extra and are used sparingly. ✅
よくある質問
「制約と固有サイズ測定」レッスンは無料ですか?
はい。「制約と固有サイズ測定」の完全なテキストはこのウェブで無料で読めます。インタラクティブに演習し(組み込みコードエディタと24時間対応のAIチューター)、Jetpack Compose Academyコースの残りをアンロックするには、CoddyKit PROにアップグレードしてください。 Jetpack Compose Academyコースには全4レッスンが含まれています。
「制約と固有サイズ測定」で何を学びますか?
親と子の間でサイズを調整します。 ブラウザで直接実行するハンズオンコードでJetpack Compose Academyを演習し、24時間対応のAIチューターがレッスンを進める中での質問に答えます。
Jetpack Compose Academyを始めるのに経験は必要ですか?
事前経験は必要ありません。CoddyKitのJetpack Compose Academyは初級者から上級者向けに構成されているため、ここから始めるか最初から始めて、自分のペースで進むことができます。 これはレッスン3/4です。
「制約と固有サイズ測定」レッスンにはどのくらい時間がかかりますか?
ほとんどのCoddyKitレッスンは約5~10分かかります。各レッスンはコンパクトでインタラクティブなので、着実に進歩し、ウェブとアプリ全体で正確に前回の場所から再開できます。
このJetpack Compose Academyレッスンでコードを書いて実行できますか?
はい。すべてのJetpack Compose Academyレッスンに組み込みコードエディタが含まれているため、ブラウザでリアルコードを書いて実行し、即座のAIフィードバックを取得できます。ローカル設定は不要です。