Class FlexLayout
Definition
- 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.
public class FlexLayout : LayoutGroup, IDisposable, ILayoutParent
- Inheritance
- Implements
-
System.IDisposable
Constructors
View SourceFlexLayout()
Creates a FlexLayout object.
Declaration
public FlexLayout()
Properties
View SourceAlignment
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
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. |
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
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. |
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
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. |
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
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. |
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
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. |
Methods
View SourceDispose()
Declaration
public void Dispose()
Dispose(DisposeTypes)
Declaration
protected virtual void Dispose(DisposeTypes type)
Parameters
Type | Name | Description |
---|---|---|
DisposeTypes | type |
GetFlexAlignmentSelf(View)
Gets the alignment self of the child view.
Declaration
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 |
See Also
View SourceGetFlexAspectRatio(View)
Gets the aspect ratio of the child view.
Declaration
public static float GetFlexAspectRatio(View view)
Parameters
Type | Name | Description |
---|---|---|
View | view | The child view. |
Returns
Type | Description |
---|---|
float | The value of aspect ratio |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | The |
See Also
View SourceGetFlexBasis(View)
Gets the basis of the child view.
Declaration
public static float GetFlexBasis(View view)
Parameters
Type | Name | Description |
---|---|---|
View | view | The child view. |
Returns
Type | Description |
---|---|
float | The value of basis |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | The |
See Also
View SourceGetFlexGrow(View)
Gets the grow of the child view.
Declaration
public static float GetFlexGrow(View view)
Parameters
Type | Name | Description |
---|---|---|
View | view | The child view. |
Returns
Type | Description |
---|---|
float | The value of grow |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | The |
See Also
View SourceGetFlexPositionType(View)
Gets the position type of the child view.
Declaration
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 |
See Also
View SourceGetFlexShrink(View)
Gets the shrink of the child view.
Declaration
public static float GetFlexShrink(View view)
Parameters
Type | Name | Description |
---|---|---|
View | view | The child view. |
Returns
Type | Description |
---|---|
float | The value of shrink |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | The |
See Also
View SourceOnChildAdd(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
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. |
OnChildRemove(LayoutItem)
Callback when child is removed from container.
Declaration
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. |
OnLayout(bool, LayoutLength, LayoutLength, LayoutLength, LayoutLength)
Assign a size and position to each of its children.
Declaration
protected override void OnLayout(bool changed, LayoutLength left, LayoutLength top, LayoutLength right, LayoutLength bottom)
Parameters
Type | Name | Description |
---|---|---|
bool | 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
View SourceOnMeasure(MeasureSpecification, MeasureSpecification)
Measure the layout and its content to determine the measured width and the measured height.
Declaration
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
View SourceSetFlexAlignmentSelf(View, 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
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 |
System.ArgumentException | The |
SetFlexAspectRatio(View, float)
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
public static void SetFlexAspectRatio(View view, float value)
Parameters
Type | Name | Description |
---|---|---|
View | view | The child view. |
float | value | The value of aspect ratio |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | The |
System.ArgumentException | The |
SetFlexBasis(View, float)
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
public static void SetFlexBasis(View view, float value)
Parameters
Type | Name | Description |
---|---|---|
View | view | The child view. |
float | value | The value of basis |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | The |
System.ArgumentException | The |
SetFlexGrow(View, float)
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
public static void SetFlexGrow(View view, float value)
Parameters
Type | Name | Description |
---|---|---|
View | view | The child view. |
float | value | The value of flex |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | The |
System.ArgumentException | The |
SetFlexPositionType(View, 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
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 |
System.ArgumentException | The |
SetFlexShrink(View, float)
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
public static void SetFlexShrink(View view, float value)
Parameters
Type | Name | Description |
---|---|---|
View | view | The child view. |
float | value | The value of shrink |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | The |
System.ArgumentException | The |