W3Cschool
恭喜您成為首批注冊用戶
獲得88經(jīng)驗(yàn)值獎(jiǎng)勵(lì)
空白填充組件,在容器主軸方向上,空白填充組件具有自動(dòng)填充容器空余部分的能力。僅當(dāng)父組件為Row/Column/Flex時(shí)生效。
該組件從API Version 7開始支持。后續(xù)版本如有新增內(nèi)容,則采用上角標(biāo)單獨(dú)標(biāo)記該內(nèi)容的起始版本。
Blank(min?: number | string)
從API version 9開始,該接口支持在ArkTS卡片中使用。
參數(shù):
參數(shù)名 | 參數(shù)類型 | 必填 | 參數(shù)描述 |
---|---|---|---|
min | number | string | 否 | 空白填充組件在容器主軸上的最小大小。 默認(rèn)值:0 說明: 不支持設(shè)置百分比。負(fù)值使用默認(rèn)值。當(dāng)最小值大于容器可用空間時(shí),使用最小值作為自身大小并超出容器。 |
除支持通用屬性外,還支持以下屬性:
名稱 | 參數(shù)類型 | 描述 |
---|---|---|
color | 設(shè)置空白填充的填充顏色。 默認(rèn)值:Color.Transparent 從API version 9開始,該接口支持在ArkTS卡片中使用。 |
Blank組件在橫豎屏占滿空余空間效果。
- // xxx.ets
- @Entry
- @Component
- struct BlankExample {
- build() {
- Column() {
- Row() {
- Text('Bluetooth').fontSize(18)
- Blank()
- Toggle({ type: ToggleType.Switch }).margin({ top: 14, bottom: 14, left: 6, right: 6 })
- }.width('100%').backgroundColor(0xFFFFFF).borderRadius(15).padding({ left: 12 })
- }.backgroundColor(0xEFEFEF).padding(20)
- }
- }
豎屏狀態(tài)
橫屏狀態(tài)
Blank組件的父組件未設(shè)置寬度時(shí),min參數(shù)的使用效果。
- // xxx.ets
- @Entry
- @Component
- struct BlankExample {
- build() {
- Column({ space: 20 }) {
- // blank父組件不設(shè)置寬度時(shí),Blank失效,可以通過設(shè)置min最小寬度填充固定寬度
- Row() {
- Text('Bluetooth').fontSize(18)
- Blank().color(Color.Yellow)
- Toggle({ type: ToggleType.Switch }).margin({ top: 14, bottom: 14, left: 6, right: 6 })
- }.backgroundColor(0xFFFFFF).borderRadius(15).padding({ left: 12 })
- Row() {
- Text('Bluetooth').fontSize(18)
- // 設(shè)置最小寬度為160
- Blank('160').color(Color.Yellow)
- Toggle({ type: ToggleType.Switch }).margin({ top: 14, bottom: 14, left: 6, right: 6 })
- }.backgroundColor(0xFFFFFF).borderRadius(15).padding({ left: 12 })
- }.backgroundColor(0xEFEFEF).padding(20).width('100%')
- }
- }
Blank父組件未設(shè)置寬度時(shí),子組件間無空白填充,使用min參數(shù)設(shè)置填充尺寸
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)系方式:
更多建議: