MultiComposableMeasurables

class MultiComposableMeasurables : List<Measurable>
kotlin.Any
   ↳ androidx.ui.core.MultiComposableMeasurables

A List of Measurables passed in as the argument to the Layout measureBlock when using the vararg variant.

Summary

Public methods

operator List<Measurable>
get(children: () -> Unit)

When multiple Composable children are passed into Layout, the Measurables for each Composable can be retrieved using this method.

Public methods

get

operator fun get(children: () -> Unit): List<Measurable>

When multiple Composable children are passed into Layout, the Measurables for each Composable can be retrieved using this method.

import androidx.ui.core.Layout

Layout(header, footer) { children, constraints ->
    val headerMeasurables = children[header]
    val footerMeasurables = children[footer]

    val headerPlaceables = headerMeasurables.map { child ->
        // You should use appropriate constraints.
        // This is shortened for the sake of a short example.
        child.measure(Constraints.tightConstraints(100.ipx, 100.ipx))
    }
    val footerPlaceables = footerMeasurables.map { child ->
        child.measure(constraints)
    }
    // Size should be derived from headerMeasurables and footerMeasurables measured
    // sizes, but this is shortened for the purposes of the example.
    layout(100.ipx, 100.ipx) {
        headerPlaceables.forEach { it.place(0.ipx, 0.ipx) }
        footerPlaceables.forEach { it.place(0.ipx, 0.ipx) }
    }
}