androidx.compose.foundation.layout
paddingFrom
Function · from org.jetbrains.compose.foundation:foundation-layout:1.12.2
No hand-written docs yet.
A Modifier that can add padding to position the content according to specified distances from its bounds to an [alignment line]AlignmentLine. Whether the positioning is vertical or horizontal is defined by the orientation of the given alignmentLine (if the line is horizontal, before and after will refer to distances from top and bottom, otherwise they will refer to distances from start and end). The opposite axis sizing and positioning will remain unaffected. The modified layout will try to include the required padding, subject to the incoming max layout constraints, such that the distance from its bounds to the alignmentLine of the content will be before and after, respectively. When the max constraints do not allow this, satisfying the before requirement will have priority over after. When the modified layout is min constrained in the affected layout direction and the padded layout is smaller than the constraint, the modified layout will satisfy the min constraint and the content will be positioned to satisfy the before requirement if specified, or the after requirement otherwise.
Form 1
fun Modifier.paddingFrom(
alignmentLine: AlignmentLine,
before: Dp = Dp.Unspecified,
after: Dp = Dp.Unspecified,
): Modifier
alignmentLine: AlignmentLineRequired
alignmentLine: AlignmentLineRequiredthe alignment line relative to which the padding is defined
before: DpOptional
before: DpOptionalDefault: Dp.Unspecified
the distance between the container's top edge and the horizontal alignment line, or the container's start edge and the vertical alignment line
after: DpOptional
after: DpOptionalDefault: Dp.Unspecified
the distance between the container's bottom edge and the horizontal alignment line, or the container's end edge and the vertical alignment line
Form 2
fun Modifier.paddingFrom(
alignmentLine: AlignmentLine,
before: TextUnit = TextUnit.Unspecified,
after: TextUnit = TextUnit.Unspecified,
): Modifier
before: TextUnitOptional
before: TextUnitOptionalDefault: TextUnit.Unspecified
the distance between the container's top edge and the horizontal alignment line, or the container's start edge and the vertical alignment line
after: TextUnitOptional
after: TextUnitOptionalDefault: TextUnit.Unspecified
the distance between the container's bottom edge and the horizontal alignment line, or the container's end edge and the vertical alignment line
Same as above: alignmentLine.
Library docs
A Modifier that can add padding to position the content according to specified distances from
its bounds to an [alignment line]AlignmentLine. Whether the positioning is vertical or
horizontal is defined by the orientation of the given alignmentLine (if the line is horizontal,
before and after will refer to distances from top and bottom, otherwise they will refer to
distances from start and end). The opposite axis sizing and positioning will remain unaffected.
The modified layout will try to include the required padding, subject to the incoming max layout
constraints, such that the distance from its bounds to the alignmentLine of the content will be
before and after, respectively. When the max constraints do not allow this, satisfying the
before requirement will have priority over after. When the modified layout is min constrained
in the affected layout direction and the padded layout is smaller than the constraint, the
modified layout will satisfy the min constraint and the content will be positioned to satisfy the
before requirement if specified, or the after requirement otherwise.
Example usage: