ts-container-column.md 2.8 KB
Newer Older
E
ester.zhou 已提交
1
# Column
Z
zengyawen 已提交
2

E
ester.zhou 已提交
3
The **<Column\>** component lays out child components vertically.
Z
zengyawen 已提交
4

E
ester.zhou 已提交
5
>  **NOTE**
E
ester.zhou 已提交
6
>
E
ester.zhou 已提交
7
>  This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version.
Z
zengyawen 已提交
8

E
ester.zhou 已提交
9 10 11

## Child Components

E
ester.zhou 已提交
12
Supported
E
ester.zhou 已提交
13 14 15 16


## APIs

E
ester.zhou 已提交
17
Column(value?:{space?: string | number})
E
ester.zhou 已提交
18

E
ester.zhou 已提交
19
**Parameters**
E
ester.zhou 已提交
20

E
ester.zhou 已提交
21 22 23
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| space | string \| number | No| Space between two adjacent child components in the vertical layout.<br>Default value: **0**|
E
ester.zhou 已提交
24 25 26

## Attributes

E
ester.zhou 已提交
27
In addition to the [universal attributes](ts-universal-attributes-size.md), the following attributes are supported.
E
ester.zhou 已提交
28

E
ester.zhou 已提交
29 30 31 32
| Name| Type| Description|
| -------- | -------- | -------- |
| alignItems | [HorizontalAlign](ts-appendix-enums.md#horizontalalign) | Alignment mode of the child components in the horizontal direction.<br>Default value: **HorizontalAlign.Center**|
| justifyContent<sup>8+</sup> | [FlexAlign](ts-container-flex.md) | Alignment mode of the child components in the vertical direction.<br>Default value: **FlexAlign.Start**|
E
ester.zhou 已提交
33 34

## Example
Z
zengyawen 已提交
35

E
ester.zhou 已提交
36 37
```ts
// xxx.ets
Z
zengyawen 已提交
38 39 40 41
@Entry
@Component
struct ColumnExample {
  build() {
E
ester.zhou 已提交
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
    Column() {
        Text('space').fontSize(9).fontColor(0xCCCCCC).width('90%')
        Column({ space: 5 }) {
          Column().width('100%').height(30).backgroundColor(0xAFEEEE)
          Column().width('100%').height(30).backgroundColor(0x00FFFF)
        }.width('90%').height(100).border({ width: 1 })

        Text('alignItems(Start)').fontSize(9).fontColor(0xCCCCCC).width('90%')
        Column() {
          Column().width('50%').height(30).backgroundColor(0xAFEEEE)
          Column().width('50%').height(30).backgroundColor(0x00FFFF)
        }.alignItems(HorizontalAlign.Start).width('90%').border({ width: 1 })

        Text('alignItems(End)').fontSize(9).fontColor(0xCCCCCC).width('90%')
        Column() {
          Column().width('50%').height(30).backgroundColor(0xAFEEEE)
          Column().width('50%').height(30).backgroundColor(0x00FFFF)
        }.alignItems(HorizontalAlign.End).width('90%').border({ width: 1 })

        Text('justifyContent(Center)').fontSize(9).fontColor(0xCCCCCC).width('90%')
        Column() {
          Column().width('30%').height(30).backgroundColor(0xAFEEEE)
          Column().width('30%').height(30).backgroundColor(0x00FFFF)
        }.height('15%').border({ width: 1 }).justifyContent(FlexAlign.Center)
E
ester.zhou 已提交
66

E
ester.zhou 已提交
67 68 69 70 71
        Text('justifyContent(End)').fontSize(9).fontColor(0xCCCCCC).width('90%')
        Column() {
          Column().width('30%').height(30).backgroundColor(0xAFEEEE)
          Column().width('30%').height(30).backgroundColor(0x00FFFF)
        }.height('15%').border({ width: 1 }).justifyContent(FlexAlign.End)
Z
zengyawen 已提交
72 73 74 75 76
    }.width('100%').padding({ top: 5 })
  }
}
```

E
esterzhou 已提交
77
![Column](figures/Column.png)