Dimension Settings
Note:
Currently in the beta phase.
Configure dimension-related properties such as component width, height, size, padding, and margin.
Import Module
import kit.ArkUI.*
func width(Option<Length>)
func width(value: Option<Length>): T
Function: Sets the width of a component.
Note:
- In the TextInput component, setting width to LengthMetrics.AUTO means auto-adapting to the text width.
- In the AlphabetIndexer component, setting width to LengthMetrics.AUTO means auto-adapting to the width of the largest index item.
System Capability: SystemCapability.ArkUI.ArkUI.Full
Since: 22
Parameters:
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| value | Option<Length> | Yes | - | Component width |
Return Value:
| Type | Description |
|---|---|
| T | Returns generic method interface type |
func height(?Length)
func height(value: Option<Length>): T
Function: Sets the height of a component.
Note:
In the Row, Column, RelativeContainer components, setting width and height to LengthMetrics.AUTO means auto-adapting to child components.
System Capability: SystemCapability.ArkUI.ArkUI.Full
Since: 22
Parameters:
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| value | Option<Length> | Yes | - | Component height |
Return Value:
| Type | Description |
|---|---|
| T | Returns generic method interface type |
func size(?Length, ?Length)
func size(width!: ?Length, height!: ?Length): T
Function: Sets the dimensions of a component.
System Capability: SystemCapability.ArkUI.ArkUI.Full
Since: 22
Parameters:
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| width | ?Length | Yes | - | Named parameter. Component width Initial value: 0.0.vp. |
| height | ?Length | Yes | - | Named parameter. Component height Initial value: 0.0.vp. |
Return Value:
| Type | Description |
|---|---|
| T | Returns generic method interface type |
func padding(?Length)
func padding(value: ?Length): T
Function: Sets the padding of a component.
System Capability: SystemCapability.ArkUI.ArkUI.Full
Since: 22
Parameters:
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| value | ?Length | Yes | - | Component padding |
Return Value:
| Type | Description |
|---|---|
| T | Returns generic method interface type |
func padding(?Length, ?Length, ?Length, ?Length)
func padding(top!: ?Length, right!: ?Length, bottom!: ?Length, left!: ?Length): T
Function: Sets the padding for each side of a component individually.
System Capability: SystemCapability.ArkUI.ArkUI.Full
Since: 22
Parameters:
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| top | ?Length | Yes | - | Named parameter. Top padding Initial value: 0.vp. |
| right | ?Length | Yes | - | Named parameter. Right padding Initial value: 0.vp. |
| bottom | ?Length | Yes | - | Named parameter. Bottom padding Initial value: 0.vp. |
| left | ?Length | Yes | - | Named parameter. Left padding Initial value: 0.vp. |
Return Value:
| Type | Description |
|---|---|
| T | Returns generic method interface type |
func margin(?Length)
func margin(value: ?Length): T
Function: Sets the margin of a component.
System Capability: SystemCapability.ArkUI.ArkUI.Full
Since: 22
Parameters:
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| value | ?Length | Yes | - | Component margin |
Return Value:
| Type | Description |
|---|---|
| T | Returns generic method interface type |
func margin(?Length, ?Length, ?Length, ?Length)
func margin(top!: ?Length, right!: ?Length, bottom!: ?Length, left!: ?Length): T
Function: Sets the margin for each side of a component individually.
System Capability: SystemCapability.ArkUI.ArkUI.Full
Since: 22
Parameters:
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| top | ?Length | Yes | - | Named parameter. Top margin Initial value: 0.vp. |
| right | ?Length | Yes | - | Named parameter. Right margin Initial value: 0.vp. |
| bottom | ?Length | Yes | - | Named parameter. Bottom margin Initial value: 0.vp. |
| left | ?Length | Yes | - | Named parameter. Left margin Initial value: 0.vp. |
Return Value:
| Type | Description |
|---|---|
| T | Returns generic method interface type |
func layoutWeight(?Int32)
func layoutWeight(value: ?Int32): T
Function: Sets the layout weight of a component.
System Capability: SystemCapability.ArkUI.ArkUI.Full
Since: 22
Parameters:
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| value | ?Int32 | Yes | - | Component layout weight Initial value: 0. |
Return Value:
| Type | Description |
|---|---|
| T | Returns generic method interface type |
func aspectRatio(Float64)
func aspectRatio(value: Float64): T
Function: Sets the aspect ratio of a component.
System Capability: SystemCapability.ArkUI.ArkUI.Full
Since: 22
Parameters:
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| value | Float64 | Yes | - | Component aspect ratio |
Return Value:
| Type | Description |
|---|---|
| T | Returns generic method interface type |
func displayPriority(?Int32)
func displayPriority(value: ?Int32): T
Function: Sets the display priority of a component.
System Capability: SystemCapability.ArkUI.ArkUI.Full
Since: 22
Parameters:
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| value | ?Int32 | Yes | - | Component display priority Initial value: 1. |
Return Value:
| Type | Description |
|---|---|
| T | Returns generic method interface type |