Constraints & Intrinsic Measurements
Negotiate size between parent and child.
Constraints & Intrinsic Measurements is a free Jetpack Compose Academy lesson on CoddyKit — lesson 3 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Jetpack Compose Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.
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. ✅
Frequently asked questions
Is the “Constraints & Intrinsic Measurements” lesson free?
Yes — the full text of “Constraints & Intrinsic Measurements” is free to read here on the web, and the Jetpack Compose Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Jetpack Compose Academy course, upgrade to CoddyKit PRO.
What will I learn in “Constraints & Intrinsic Measurements”?
Negotiate size between parent and child. You practise Jetpack Compose Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start Jetpack Compose Academy?
No prior experience is required. Jetpack Compose Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 3 of 4, so you can start here or from the beginning and move at your own pace.
How long does the “Constraints & Intrinsic Measurements” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this Jetpack Compose Academy lesson?
Yes. Every Jetpack Compose Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.
All lessons in this course
- The Measure & Place Model
- Writing a Layout Composable
- Constraints & Intrinsic Measurements
- A FlowRow That Wraps Chips