W3Cschool
恭喜您成為首批注冊(cè)用戶
獲得88經(jīng)驗(yàn)值獎(jiǎng)勵(lì)
該組件從API Version 7開始支持。后續(xù)版本如有新增內(nèi)容,則采用上角標(biāo)單獨(dú)標(biāo)記該內(nèi)容的起始版本。
Column(value?: {space?: string | number})
從API version 9開始,該接口支持在ArkTS卡片中使用。
參數(shù):
參數(shù)名 | 參數(shù)類型 | 必填 | 參數(shù)描述 |
---|---|---|---|
space | string | number | 否 | 縱向布局元素垂直方向間距。 從API version 9開始,space為負(fù)數(shù)或者justifyContent設(shè)置為FlexAlign.SpaceBetween、FlexAlign.SpaceAround、FlexAlign.SpaceEvenly時(shí)不生效。 默認(rèn)值:0 說明: 可選值為大于等于0的數(shù)字,或者可以轉(zhuǎn)換為數(shù)字的字符串。 |
除支持通用屬性外,還支持以下屬性:
名稱 | 參數(shù)類型 | 描述 |
---|---|---|
alignItems | 設(shè)置子組件在水平方向上的對(duì)齊格式。 默認(rèn)值:HorizontalAlign.Center 從API version 9開始,該接口支持在ArkTS卡片中使用。 | |
justifyContent8+ | 設(shè)置子組件在垂直方向上的對(duì)齊格式。 默認(rèn)值:FlexAlign.Start 從API version 9開始,該接口支持在ArkTS卡片中使用。 |
- // xxx.ets
- @Entry
- @Component
- struct ColumnExample {
- build() {
- Column({ space: 5 }) {
- // 設(shè)置子元素垂直方向間距為5
- Text('space').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 })
- // 設(shè)置子元素水平方向?qū)R方式
- Text('alignItems(Start)').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)').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('alignItems(Center)').width('90%')
- Column() {
- Column().width('50%').height(30).backgroundColor(0xAFEEEE)
- Column().width('50%').height(30).backgroundColor(0x00FFFF)
- }.alignItems(HorizontalAlign.Center).width('90%').border({ width: 1 })
- // 設(shè)置子元素垂直方向的對(duì)齊方式
- Text('justifyContent(Center)').width('90%')
- Column() {
- Column().width('90%').height(30).backgroundColor(0xAFEEEE)
- Column().width('90%').height(30).backgroundColor(0x00FFFF)
- }.height(100).border({ width: 1 }).justifyContent(FlexAlign.Center)
- Text('justifyContent(End)').width('90%')
- Column() {
- Column().width('90%').height(30).backgroundColor(0xAFEEEE)
- Column().width('90%').height(30).backgroundColor(0x00FFFF)
- }.height(100).border({ width: 1 }).justifyContent(FlexAlign.End)
- }.width('100%').padding({ top: 5 })
- }
- }
Copyright©2021 w3cschool編程獅|閩ICP備15016281號(hào)-3|閩公網(wǎng)安備35020302033924號(hào)
違法和不良信息舉報(bào)電話:173-0602-2364|舉報(bào)郵箱:jubao@eeedong.com
掃描二維碼
下載編程獅App
編程獅公眾號(hào)
聯(lián)系方式:
更多建議: