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

Z
zengyawen 已提交
3

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


Z
zengyawen 已提交
8
The **&lt;Column&gt;** component lays out child components vertically.
E
ester.zhou 已提交
9 10 11


## Required Permissions
Z
zengyawen 已提交
12 13 14

None

E
ester.zhou 已提交
15 16 17

## Child Components

Z
zengyawen 已提交
18
This component can contain child components.
E
ester.zhou 已提交
19 20 21 22 23 24 25 26


## APIs

Column(value:{space?: Length})


- Parameters
H
HelloCrease 已提交
27 28 29
    | Name  | Type   | Mandatory | Default Value | Description                              |
    | ----- | ------ | --------- | ------------- | ---------------------------------------- |
    | space | Length | No        | 0             | Space between any two adjacent child components in the vertical layout. |
E
ester.zhou 已提交
30 31 32 33


## Attributes

H
HelloCrease 已提交
34 35 36 37
| Name                        | Type                              | Default Value          | Description                              |
| --------------------------- | --------------------------------- | ---------------------- | ---------------------------------------- |
| alignItems                  | HorizontalAlign                   | HorizontalAlign.Center | Alignment mode of child components in the horizontal direction. |
| justifyContent<sup>8+</sup> | [FlexAlign](ts-container-flex.md) | FlexAlign.Start        | Alignment mode of child components in the vertical direction. |
E
ester.zhou 已提交
38 39

- HorizontalAlign enums
H
HelloCrease 已提交
40 41 42
    | Name   | Description                              |
    | ------ | ---------------------------------------- |
    | Start  | Aligned with the start edge in the same direction as the language in use. |
43
    | Center | Aligned to the center. This is the default alignment mode. |
H
HelloCrease 已提交
44
    | End    | Aligned with the end edge in the same direction as the language in use. |
E
ester.zhou 已提交
45 46 47


## Example
Z
zengyawen 已提交
48

Z
zengyawen 已提交
49

Z
zengyawen 已提交
50 51 52 53 54
```
@Entry
@Component
struct ColumnExample {
  build() {
E
ester.zhou 已提交
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83
    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)
        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 已提交
84 85 86 87 88
    }.width('100%').padding({ top: 5 })
  }
}
```

H
HelloCrease 已提交
89
![](figures/Column.png)