Adds a layout into your app.

lay = ui.addLayout( parent, type, options?, width?, height? ) → ui object: Layout

There are 5 types of layouts: "Linear", "Absolute", "Frame", "Slide" and "Card". Layouts are transparent by default but you can set a background color or a background image. You can add child objects to the Layout by passing the layout as parent when initializing a control. By default, Layouts will auto-size to wrap and fit their contents but you have 3 more options as to how layout sizes within it's parent: FillXY, FillX, and FillY.

Linear Layouts

Linear layouts are probably the most common type and are used to organize controls in the Vertical or Horizontal orientation on the screen. You can also pass alignment options. For vertical alignment you can pass Top, VCenter, and Bottom. For horizontal alignment you can pass Left, Center, and Right. These will align your children accordingly. For children spacing, see childSpacing property below.

Absolute Layouts

Absolute layouts ignore all alignment options and allow the absolute positioning of controls by calling the setPosition method of each child control. However, you are encouraged to use linear layouts for most of your programs, unless it is absolutely necessary.

Frame Layouts

Frame layouts are used to display objects in front or behind each other. Everytime a child control is added, the new control is placed in a new layer in front of the previously added control at the top left of the frame. You can then use setPosition method of the child control to position it relative to the frame.

Slide Layouts

Slide layouts are used to display carousels or swipeable contents. The same as the Frame layout, this will add a new layer when a new control is added with a swipeable behaviour. You can pass alignment options to align your children within the Slide layout layer. Please note that Vertical and Horizontal options will be the direction of the swipe. If your parent layout is of type Slide, do not add setOnTouch callback handler in order for the slide layout to work perfectly.

Card Layouts

Card layouts are used to display surfaces with elevation and a rounder corners to emphasize its contents. This type of layout has default values for padding. You can clear the padding by setting the padding property to 0. If you want to use the material design card implementation, refer to the Card component.

Dimensions

To set the width and height of a layout, pass a width and height argument as a decimal fraction of its parent's width and height.
In some scenarios where you want the layout to occupy the available space, you can add "FillXY" in the options argument to fill the available width and height of its parent. Similarly, when you want to fill the available horizontal space, you can pass "FillX" and "FillY" for filling the available vertical space.

Here are the available methods for the Layout Component.

Examples

Example - Main layout click to expand contents 

Example - Bottom aligned with margins click to expand contents 

Example - Orientation and spacing click to expand contents 

Example - Slide Layout click to expand contents 

Example - Player control using Card layout click to expand contents 

Properties

The following properties are available on the Layout object:

absHeightNumber
absLeftNumber
absTopNumber
absWidthNumber
alignmentString
backColorString
backImageString
borderNumber
borderColorString
borderStyleString
childMarginsList
childrenList
childSpacingString
cornerRadiusNumber
currentSlideNumber
disabledBoolean
elObject
elevationNumber
elStyleString
fontFileString
heightNumber
isVisibleBoolean
layoutTypeString
leftNumber
marginsList
opacityNumber
optionsString
orientationString
paddingList
parentObject
positionObject
rotationNumber
textColorString
textSizeNumber
topNumber
typeString
variantString
visibilityString
widthNumber

Methods

The following methods are available on the Layout object:

clear()
getChildOrder( child ) → Number
getPosition( options ) → Object
gone()
goto( index )
hasChild( child ) → Boolean
hide()
next()
setScale( x, y )
show()