0Pricing
Jetpack Compose Academy · Lektion

Das Measure-and-Place-Modell

Verstehen Sie das Single-Pass-Layout von Compose.

Das Measure-and-Place-Modell ist eine kostenlose Jetpack Compose Academy-Lektion auf CoddyKit. Dies ist Lektion 1 von 4. Du kannst die komplette Lektion unten kostenlos lesen – dann übst du sie direkt im Browser mit einem integrierten Code-Editor und einem KI-Tutor rund um die Uhr. Sie ist Teil des Jetpack Compose Academy-Lernpfads, und dein Fortschritt wird über Web und CoddyKit-App synchronisiert. Der Jetpack Compose Academy-Kurs umfasst insgesamt 4 Lektionen.

Teile dieser Lektion wurden noch nicht übersetzt und werden auf Englisch angezeigt.

When Built-In Layouts Are Not Enough

Column, Row, and Box cover most screens. But sometimes you need total control over where children go. That is when you build a custom layout. 🎨

Compose Lays Out in One Pass

Unlike the old View system, Compose measures and places everything in a single pass. There is no expensive measure-then-measure-again cycle.

Two Steps: Measure, Then Place

Every layout does two things in order. First it measures each child to learn its size. Then it places each child at a chosen position.

Measurables Are Children Not Yet Sized

A parent receives its children as measurables. A measurable is a child you have not measured yet, like a parcel before you weigh it. 📦

Measuring Produces a Placeable

Call measure on a measurable and you get a placeable back. The placeable knows its final width and height and is ready to be positioned.

val placeable = measurable.measure(constraints)
val w = placeable.width

Constraints Set the Size Limits

When you measure, you pass constraints: the min and max width and height the child is allowed. The child picks a size within those bounds.

Measure Each Child Exactly Once

The single-pass rule means you must measure each child only once. Measuring the same child twice throws an error at runtime.

The Parent Decides Its Own Size

After measuring children, the parent reports its own width and height. It usually sizes itself to wrap the children it just measured.

layout(width, height) {
  // place children here
}

Placing Sets Each Child's Position

Inside the layout block you call placeRelative on each placeable, giving it an x and y. That is where the child lands on screen.

placeable.placeRelative(x = 0, y = 0)

placeRelative Respects Direction

Prefer placeRelative over place. It automatically mirrors positions for right-to-left languages, so your layout works everywhere. 🌍

This Model Powers Every Layout

Column, Row, and your future custom layouts all follow this same measure-then-place rhythm. Learn it once and you understand all of Compose layout.

Quick Check

What do you get back after measuring a measurable?

Recap: The Measure & Place Model

Compose lays out in one pass: measure each child once within constraints to get placeables, then place them. This model drives every layout you will build. ✅

Häufig gestellte Fragen

Ist die Lektion „Das Measure-and-Place-Modell“ kostenlos?

Ja — der vollständige Text von „Das Measure-and-Place-Modell“ ist hier im Web kostenlos zu lesen. Um sie interaktiv zu üben (integrierter Code-Editor und 24/7 KI-Tutor) und den Rest des Jetpack Compose Academy-Kurses freizuschalten, upgrade auf CoddyKit PRO. Der Jetpack Compose Academy-Kurs umfasst insgesamt 4 Lektionen.

Was lerne ich in „Das Measure-and-Place-Modell“?

Verstehen Sie das Single-Pass-Layout von Compose. Du übst Jetpack Compose Academy mit praktischem Code, den du direkt im Browser ausführst, und ein 24/7 KI-Tutor beantwortet deine Fragen während du die Lektion bearbeitest.

Brauche ich Erfahrung, um Jetpack Compose Academy zu starten?

Keine Vorkenntnisse erforderlich. Jetpack Compose Academy auf CoddyKit ist für Anfänger bis fortgeschrittene Lernende strukturiert, sodass du hier starten oder von Anfang an beginnen und in deinem eigenen Tempo voranschreiten kannst. Dies ist Lektion 1 von 4.

Wie lange dauert die Lektion „Das Measure-and-Place-Modell“?

Die meisten CoddyKit-Lektionen dauern etwa 5–10 Minuten. Jede ist kompakt und interaktiv, sodass du stetig Fortschritte machst und genau dort weitermachst, wo du aufgehört hast – im Web und in der App.

Kann ich in dieser Jetpack Compose Academy-Lektion Code schreiben und ausführen?

Ja. Jede Jetpack Compose Academy-Lektion enthält einen integrierten Code-Editor, sodass du echten Code direkt in deinem Browser schreibst und ausführst und sofort KI-Feedback erhältst — ohne lokale Einrichtung erforderlich.

Alle Lektionen in diesem Kurs

  1. Das Measure-and-Place-Modell
  2. Eine Layout-Composable schreiben
  3. Constraints und intrinsische Messungen
  4. Eine FlowRow, die Chips umbricht
← Zurück zu Jetpack Compose Academy