Android 12 Developer Preview is here! Try it out, and give us your feedback!

PercentLayoutInfo

open class PercentLayoutInfo
kotlin.Any
   ↳ androidx.percentlayout.widget.PercentLayoutHelper.PercentLayoutInfo

Container for information about percentage dimensions and margins. It acts as an extension for LayoutParams.

Summary

Public constructors

Public methods
open Unit
fillLayoutParams(params: LayoutParams!, widthHint: Int, heightHint: Int)

Fills the ViewGroup.LayoutParams#width and ViewGroup.LayoutParams#height fields of the passed ViewGroup.LayoutParams object based on currently set percentage values.

open Unit
fillMarginLayoutParams(params: MarginLayoutParams!, widthHint: Int, heightHint: Int)

open Unit
fillMarginLayoutParams(view: View!, params: MarginLayoutParams!, widthHint: Int, heightHint: Int)

Fills the margin fields of the passed ViewGroup.MarginLayoutParams object based on currently set percentage values and the current layout direction of the passed View.

open Unit

Restores original dimensions after they were changed for percentage based values.

open Unit

Restores the original dimensions and margins after they were changed for percentage based values.

open String

Properties
Float

The decimal value of the percentage-based aspect ratio.

Float

The decimal value of the percentage-based bottom margin.

Float

The decimal value of the percentage-based end margin.

Float

The decimal value of the percentage-based height.

Float

The decimal value of the percentage-based left margin.

Float

The decimal value of the percentage-based right margin.

Float

The decimal value of the percentage-based start margin.

Float

The decimal value of the percentage-based top margin.

Float

The decimal value of the percentage-based width.

Public constructors

<init>

PercentLayoutInfo()

Public methods

fillLayoutParams

open fun fillLayoutParams(
    params: LayoutParams!,
    widthHint: Int,
    heightHint: Int
): Unit

Fills the ViewGroup.LayoutParams#width and ViewGroup.LayoutParams#height fields of the passed ViewGroup.LayoutParams object based on currently set percentage values.

fillMarginLayoutParams

open fun fillMarginLayoutParams(
    params: MarginLayoutParams!,
    widthHint: Int,
    heightHint: Int
): Unit

Deprecated: Use fillMarginLayoutParams(View, ViewGroup.MarginLayoutParams, int, int) for proper RTL support.

fillMarginLayoutParams

open fun fillMarginLayoutParams(
    view: View!,
    params: MarginLayoutParams!,
    widthHint: Int,
    heightHint: Int
): Unit

Fills the margin fields of the passed ViewGroup.MarginLayoutParams object based on currently set percentage values and the current layout direction of the passed View.

restoreLayoutParams

open fun restoreLayoutParams(params: LayoutParams!): Unit

Restores original dimensions after they were changed for percentage based values. You should call this method only if you previously called PercentLayoutHelper.PercentLayoutInfo#fillLayoutParams(ViewGroup.LayoutParams, int, int).

restoreMarginLayoutParams

open fun restoreMarginLayoutParams(<