Class FlexLayout

Definition

Namespace:
Tizen.NUI
Assembly:
Tizen.NUI.dll

This class implements a flex layout. The flex layout implementation is based on open source Facebook Yoga layout engine. For more information about the flex layout API and how to use it please refer to https://yogalayout.com/docs/ We implement the subset of the API in the class below.

C#
Copy
public class FlexLayout : LayoutGroup, IDisposable, ILayoutParent
Inheritance
System.Object
FlexLayout
Implements
System.IDisposable

Constructors

View Source

FlexLayout()

Creates a FlexLayout object.

Declaration
C#
Copy
public FlexLayout()
API Level: 6

Properties

View Source

Alignment

Gets/Sets the alignment of the layout content. Alignment defines the distribution of lines along the cross-axis.
This only has effect when items are wrapped to multiple lines using flex wrap.

Declaration
C#
Copy
public FlexLayout.AlignmentType Alignment { get; set; }
Property Value
Type Description
FlexLayout.AlignmentType
Exceptions
Type Condition
System.ComponentModel.InvalidEnumArgumentException

Thrown when using invalid arguments that are enumerators.

API Level: 6
View Source

Direction

Gets/Sets the flex direction in the layout. The direction of the main-axis which determines the direction that flex items are laid out.

Declaration
C#
Copy
public FlexLayout.FlexDirection Direction { get; set; }
Property Value
Type Description
FlexLayout.FlexDirection
Exceptions
Type Condition
System.ComponentModel.InvalidEnumArgumentException

Thrown when using invalid arguments that are enumerators.

API Level: 6
View Source

ItemsAlignment

Gets/Sets the alignment of the layout items. Items alignment describes how to align children along the cross axis of their container.
Align items is very similar to Justification but instead of applying to the main axis, align items applies to the cross axis.

Declaration
C#
Copy
public FlexLayout.AlignmentType ItemsAlignment { get; set; }
Property Value
Type Description
FlexLayout.AlignmentType
Exceptions
Type Condition
System.ComponentModel.InvalidEnumArgumentException

Thrown when using invalid arguments that are enumerators.

API Level: 6
View Source

Justification

Gets/Sets the justification in the layout. Justify content describes how to align children within the main axis of their container.
For example, you can use this property to center a child horizontally within a container with Direction set to Row or vertically within a container with Direction set to Column.

Declaration
C#
Copy
public FlexLayout.FlexJustification Justification { get; set; }
Property Value
Type Description
FlexLayout.FlexJustification
Exceptions
Type Condition
System.ComponentModel.InvalidEnumArgumentException

Thrown when using invalid arguments that are enumerators.

API Level: 6
View Source

WrapType

Gets/Sets the wrap in the layout. The flex wrap property is set on containers and controls what happens when children overflow the size of the container along the main axis.
By default children are forced into a single line (which can shrink elements).
If wrapping is allowed items are wrapped into multiple lines along the main axis if needed. wrap reverse behaves the same, but the order of the lines is reversed.
When wrapping lines Alignment can be used to specify how the lines are placed in the container.

Declaration
C#
Copy
public FlexLayout.FlexWrapType WrapType { get; set; }
Property Value
Type Description
FlexLayout.FlexWrapType
Exceptions
Type Condition
System.ComponentModel.InvalidEnumArgumentException

Thrown when using invalid arguments that are enumerators.

API Level: 6

Methods

View Source

Dispose()

Declaration
C#
Copy
public void Dispose()
API Level: 6
View Source

Dispose(DisposeTypes)

Declaration
C#
Copy
protected virtual void Dispose(DisposeTypes type)
Parameters
Type Name Description
DisposeTypes type
API Level: 6
View Source

GetFlexAlignmentSelf(View)

Gets the alignment self of the child view.

Declaration
C#
Copy
public static FlexLayout.AlignmentType GetFlexAlignmentSelf(View view)
Parameters
Type Name Description
View view

The child view.

Returns
Type Description
FlexLayout.AlignmentType

The value of alignment self.

Exceptions
Type Condition
System.ArgumentNullException

The view cannot be null.

API Level: 8
View Source

GetFlexAspectRatio(View)

Gets the aspect ratio of the child view.

Declaration
C#
Copy
public static float GetFlexAspectRatio(View view)
Parameters
Type Name Description
View view

The child view.

Returns
Type Description
System.Single

The value of aspect ratio

Exceptions
Type Condition
System.ArgumentNullException

The view cannot be null.

API Level: 8
View Source

GetFlexBasis(View)

Gets the basis of the child view.

Declaration
C#
Copy
public static float GetFlexBasis(View view)
Parameters
Type Name Description
View view

The child view.

Returns
Type Description
System.Single

The value of basis

Exceptions
Type Condition
System.ArgumentNullException

The view cannot be null.

API Level: 8
View Source

GetFlexGrow(View)

Gets the grow of the child view.

Declaration
C#
Copy
public static float GetFlexGrow(View view)
Parameters
Type Name Description
View view

The child view.

Returns
Type Description
System.Single

The value of grow

Exceptions
Type Condition
System.ArgumentNullException

The view cannot be null.

API Level: 8
View Source

GetFlexPositionType(View)

Gets the position type of the child view.

Declaration
C#
Copy
public static FlexLayout.PositionType GetFlexPositionType(View view)
Parameters
Type Name Description
View view

The child view.

Returns
Type Description
FlexLayout.PositionType

The value of position type

Exceptions
Type Condition
System.ArgumentNullException

The view cannot be null.

API Level: 8
View Source

GetFlexShrink(View)

Gets the shrink of the child view.

Declaration
C#
Copy
public static float GetFlexShrink(View view)
Parameters
Type Name Description
View view

The child view.

Returns
Type Description
System.Single

The value of shrink

Exceptions
Type Condition
System.ArgumentNullException

The view cannot be null.

API Level: 8
View Source

OnChildAdd(LayoutItem)

Callback when child is added to container.
Derived classes can use this to set their own child properties on the child layout's owner.

Declaration
C#
Copy
protected override void OnChildAdd(LayoutItem child)
Parameters
Type Name Description
LayoutItem child

The Layout child.

Overrides
Exceptions
Type Condition
System.ArgumentNullException

Thrown when child is null.

API Level: 6
View Source

OnChildRemove(LayoutItem)

Callback when child is removed from container.

Declaration
C#
Copy
protected override void OnChildRemove(LayoutItem child)
Parameters
Type Name Description
LayoutItem child

The Layout child.

Overrides
Exceptions
Type Condition
System.ArgumentNullException

Thrown when child is null.

API Level: 6
View Source

OnLayout(Boolean, LayoutLength, LayoutLength, LayoutLength, LayoutLength)

Assign a size and position to each of its children.

Declaration
C#
Copy
protected override void OnLayout(bool changed, LayoutLength left, LayoutLength top, LayoutLength right, LayoutLength bottom)
Parameters
Type Name Description
Boolean changed

This is a new size or position for this layout.

LayoutLength left

Left position, relative to parent.

LayoutLength top

Top position, relative to parent.

LayoutLength right

Right position, relative to parent.

LayoutLength bottom

Bottom position, relative to parent.

Overrides
API Level: 6
View Source

OnMeasure(MeasureSpecification, MeasureSpecification)

Measure the layout and its content to determine the measured width and the measured height.

Declaration
C#
Copy
protected override void OnMeasure(MeasureSpecification widthMeasureSpec, MeasureSpecification heightMeasureSpec)
Parameters
Type Name Description
MeasureSpecification widthMeasureSpec

horizontal space requirements as imposed by the parent.

MeasureSpecification heightMeasureSpec

vertical space requirements as imposed by the parent.

Overrides
API Level: 6
View Source

SetFlexAlignmentSelf(View, FlexLayout.AlignmentType)

Sets the alignment self of the child view.
Alignment self has the same options and effect as ItemsAlignment but instead of affecting the children within a container, you can apply this property to a single child to change its alignment within its parent.
Alignment self overrides any option set by the parent with ItemsAlignment.

Declaration
C#
Copy
public static void SetFlexAlignmentSelf(View view, FlexLayout.AlignmentType value)
Parameters
Type Name Description
View view

The child view.

FlexLayout.AlignmentType value

The value of alignment self.

Exceptions
Type Condition
System.ArgumentNullException

The view cannot be null.

System.ArgumentException

The value should be FlexLayout.AlignmentType.

API Level: 8
View Source

SetFlexAspectRatio(View, Single)

Sets the aspect ratio of the child view. Aspect ratio Defines as the ratio between the width and the height of a node e.g. if a node has an aspect ratio of 2 then its width is twice the size of its height.
Aspect ratio accepts any floating point value > 0. this has higher priority than flex grow.

Declaration
C#
Copy
public static void SetFlexAspectRatio(View view, float value)
Parameters
Type Name Description
View view

The child view.

System.Single value

The value of aspect ratio

Exceptions
Type Condition
System.ArgumentNullException

The view cannot be null.

System.ArgumentException

The value cannot be less than or equal to 0.0f.

API Level: 8
View Source

SetFlexBasis(View, Single)

Sets the flex basis of the child view. Flex basis is an axis-independent way of providing the default size of an item along the main axis.
Setting the flex basis of a child is similar to setting the width of that child if its parent is a container with Row or setting the height of a child if its parent is a container with Column.
The flex basis of an item is the default size of that item, the size of the item before any flex grow and flex shrink calculations are performed.

Declaration
C#
Copy
public static void SetFlexBasis(View view, float value)
Parameters
Type Name Description
View view

The child view.

System.Single value

The value of basis

Exceptions
Type Condition
System.ArgumentNullException

The view cannot be null.

System.ArgumentException

The value cannot be less than 0.0f.

API Level: 8
View Source

SetFlexGrow(View, Single)

Sets the grow of the child view. Flex grow describes how any space within a container should be distributed among its children along the main axis. After laying out its children, a container will distribute any remaining space according to the flex grow values specified by its children.
Flex grow accepts any floating point value >= 0, with 0 being the default value.
A container will distribute any remaining space among its children weighted by the child's flex grow value.

Declaration
C#
Copy
public static void SetFlexGrow(View view, float value)
Parameters
Type Name Description
View view

The child view.

System.Single value

The value of flex

Exceptions
Type Condition
System.ArgumentNullException

The view cannot be null.

System.ArgumentException

The value cannot be less than 0.0f.

API Level: 8
View Source

SetFlexPositionType(View, FlexLayout.PositionType)

Sets the position type of the child view.
The position type of an element defines how it is positioned within its parent. By default a child is positioned relatively. This means a child is positioned according to the normal flow of the layout, and then offset relative to that position based on the values of Margin.
When positioned absolutely an element doesn't take part in the normal layout flow. It is instead laid out independent of its siblings. The position is determined based on the Margin.

Declaration
C#
Copy
public static void SetFlexPositionType(View view, FlexLayout.PositionType value)
Parameters
Type Name Description
View view

The child view.

FlexLayout.PositionType value

The value of position type.

Exceptions
Type Condition
System.ArgumentNullException

The view cannot be null.

System.ArgumentException

The value should be FlexLayout.PositionType.

API Level: 8
View Source

SetFlexShrink(View, Single)

Sets the flex shrink of the child view. Flex shrink describes how to shrink children along the main axis in the case that the total size of the children overflow the size of the container on the main axis.
Flex shrink is very similar to flex grow and can be thought of in the same way if any overflowing size is considered to be negative remaining space. These two properties also work well together by allowing children to grow and shrink as needed.
Flex shrink accepts any floating point value >= 0, with 1 being the default value. A container will shrink its children weighted by the child's flex shrink value.

Declaration
C#
Copy
public static void SetFlexShrink(View view, float value)
Parameters
Type Name Description
View view

The child view.

System.Single value

The value of shrink

Exceptions
Type Condition
System.ArgumentNullException

The view cannot be null.

System.ArgumentException

The value cannot be less than 0.0f.

API Level: 8

Implements

System.IDisposable