VerticalRuler


A vertical Ruler. Defines a line that can be used by parent layouts to align or position their children horizontally. The position of the ruler can be retrieved with Placeable.PlacementScope.current and can be set with MeasureScope.layout using RulerScope.provides or RulerScope.providesRelative.

Summary

Public companion functions

VerticalRuler
derived(calculation: Placeable.PlacementScope.(defaultValue: Float) -> Float)

Creates a VerticalRuler whose values are derived from values available in the PlacementScope, such as other VerticalRulers.

Cmn
VerticalRuler
maxOf(vararg rulers: VerticalRuler)

Creates a VerticalRuler derived from the greater value of all VerticalRulers in rulers that supply a value.

Cmn
VerticalRuler
minOf(vararg rulers: VerticalRuler)

Creates a VerticalRuler derived from the least value of all VerticalRulers in rulers that supply a value.

Cmn

Public constructors

Creates a VerticalRuler whose values are directly provided.

Cmn

Public companion functions

derived

fun derived(calculation: Placeable.PlacementScope.(defaultValue: Float) -> Float): VerticalRuler

Creates a VerticalRuler whose values are derived from values available in the PlacementScope, such as other VerticalRulers.

import androidx.compose.ui.layout.VerticalRuler
import androidx.compose.ui.unit.Dp

class PaddedRulers(val ruler: VerticalRuler, val padding: Dp) {
    val left =
        VerticalRuler.derived { defaultValue ->
            val rulerValue = ruler.current(Float.NaN)
            if (rulerValue.isNaN()) {
                defaultValue
            } else {
                rulerValue + padding.toPx()
            }
        }
    val right =
        VerticalRuler.derived { defaultValue ->
            val rulerValue = ruler.current(Float.NaN)
            if (rulerValue.isNaN()) {
                defaultValue
            } else {
                rulerValue - padding.toPx()
            }
        }
}
Parameters
calculation: Placeable.PlacementScope.(defaultValue: Float) -> Float

A function that calculates the value of the ruler

See also
minOf
maxOf

maxOf

fun maxOf(vararg rulers: VerticalRuler): VerticalRuler

Creates a VerticalRuler derived from the greater value of all VerticalRulers in rulers that supply a value. This is the bottom-most of all provided ruler values.

minOf

fun minOf(vararg rulers: VerticalRuler): VerticalRuler

Creates a VerticalRuler derived from the least value of all VerticalRulers in rulers that supply a value. This is the top-most of all provided ruler values.

Public constructors

VerticalRuler

VerticalRuler()

Creates a VerticalRuler whose values are directly provided. The developer can set the ruler value in MeasureScope.layout using RulerScope.provides or RulerScope.providesRelative.