ts-container-row.md 2.8 KB
Newer Older
Z
zengyawen 已提交
1 2
# Row

Z
zengyawen 已提交
3 4
沿水平方向布局容器。

H
HelloCrease 已提交
5 6 7 8
>  **说明:**
>
>  该组件从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。

Z
zengyawen 已提交
9 10

## 权限列表
Z
zengyawen 已提交
11 12 13



Z
zengyawen 已提交
14 15

## 子组件
Z
zengyawen 已提交
16 17 18

可以包含子组件。

Z
zengyawen 已提交
19 20 21

## 接口

L
luoying_ace_admin 已提交
22
Row(value?:{space?: Length})
Z
zengyawen 已提交
23

H
HelloCrease 已提交
24
**参数:**
Z
zengyawen 已提交
25

H
HelloCrease 已提交
26 27 28
| 参数名   | 参数类型   | 必填   | 默认值  | 参数描述      |
| ----- | ------ | ---- | ---- | --------- |
| space | Length | 否    | 0    | 横向布局元素间距。 |
Z
zengyawen 已提交
29 30 31

## 属性

H
HelloCrease 已提交
32 33 34
| 名称               | 参数类型                              | 默认值                  | 描述                |
| ---------------- | --------------------------------- | -------------------- | ----------------- |
| alignItems       | VerticalAlign                     | VerticalAlign.Center | 在垂直方向上子组件的对齐格式。   |
L
luoying_ace_admin 已提交
35
| justifyContent<sup>8+</sup> | [FlexAlign](ts-container-flex.md) | FlexAlign.Start      | 设置子组件在水平方向上的对齐格式。 |
Z
zengyawen 已提交
36

H
HelloCrease 已提交
37
## VerticalAlign枚举说明
Z
zengyawen 已提交
38

H
HelloCrease 已提交
39 40 41 42 43
| 名称     | 描述           |
| ------ | ------------ |
| Top    | 顶部对齐。        |
| Center | 居中对齐,默认对齐方式。 |
| Bottom | 底部对齐。        |
Z
zengyawen 已提交
44 45

## 示例
Z
zengyawen 已提交
46

H
HelloCrease 已提交
47 48
```ts
// xxx.ets
Z
zengyawen 已提交
49 50 51 52 53 54
@Entry
@Component
struct RowExample {
  build() {
    Column({ space: 5 }) {
      Text('space').fontSize(9).fontColor(0xCCCCCC).width('90%')
Z
zhongyuyan 已提交
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
        Row({ space: 5 }) {
          Row().width('30%').height(50).backgroundColor(0xAFEEEE)
          Row().width('30%').height(50).backgroundColor(0x00FFFF)
        }.width('90%').height(107).border({ width: 1 })

        Text('alignItems(Top)').fontSize(9).fontColor(0xCCCCCC).width('90%')
        Row() {
          Row().width('30%').height(50).backgroundColor(0xAFEEEE)
          Row().width('30%').height(50).backgroundColor(0x00FFFF)
        }.alignItems(VerticalAlign.Top).height('15%').border({ width: 1 })

        Text('alignItems(Center)').fontSize(9).fontColor(0xCCCCCC).width('90%')
        Row() {
          Row().width('30%').height(50).backgroundColor(0xAFEEEE)
          Row().width('30%').height(50).backgroundColor(0x00FFFF)
        }.alignItems(VerticalAlign.Center).height('15%').border({ width: 1 })

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

        Text('justifyContent(Center)').fontSize(9).fontColor(0xCCCCCC).width('90%')
        Row() {
          Row().width('30%').height(50).backgroundColor(0xAFEEEE)
          Row().width('30%').height(50).backgroundColor(0x00FFFF)
        }.width('90%').border({ width: 1 }).justifyContent(FlexAlign.Center)
Z
zengyawen 已提交
83 84 85 86 87
    }.width('100%')
  }
}
```

Z
zengyawen 已提交
88
![zh-cn_image_0000001174422908](figures/Row.png)