W3Cschool
恭喜您成為首批注冊用戶
獲得88經(jīng)驗(yàn)值獎勵
提供分隔器組件,分隔不同內(nèi)容塊/內(nèi)容元素。
該組件從API Version 7開始支持。后續(xù)版本如有新增內(nèi)容,則采用上角標(biāo)單獨(dú)標(biāo)記該內(nèi)容的起始版本。
除支持通用屬性外,還支持以下屬性:
名稱 | 參數(shù)類型 | 描述 |
---|---|---|
vertical | boolean | 使用水平分割線還是垂直分割線。false:水平分割線;true:垂直分割線。 默認(rèn)值:false 從API version 9開始,該接口支持在ArkTS卡片中使用。 |
color | 分割線顏色。 默認(rèn)值:'#33182431' 從API version 9開始,該接口支持在ArkTS卡片中使用。 | |
strokeWidth | number | string | 分割線寬度。 默認(rèn)值:1 單位:vp 從API version 9開始,該接口支持在ArkTS卡片中使用。 說明: 分割線的寬度不支持百分比設(shè)置。優(yōu)先級低于通用屬性height,超過通用屬性設(shè)置大小時,按照通用屬性進(jìn)行裁切。 |
lineCap | 分割線的端點(diǎn)樣式。 默認(rèn)值:LineCapStyle.Butt 從API version 9開始,該接口支持在ArkTS卡片中使用。 |
- // xxx.ets
- @Entry
- @Component
- struct DividerExample {
- build() {
- Column() {
- // 使用橫向分割線場景
- Text('Horizontal divider').fontSize(9).fontColor(0xCCCCCC)
- List() {
- ForEach([1, 2, 3], (item) => {
- ListItem() {
- Text('list' + item).width('100%').fontSize(14).fontColor('#182431').textAlign(TextAlign.Start)
- }.width(244).height(48)
- }, item => item.toString())
- }.padding({ left: 24, bottom: 8 })
- Divider().strokeWidth(8).color('#F1F3F5')
- List() {
- ForEach([4, 5], (item) => {
- ListItem() {
- Text('list' + item).width('100%').fontSize(14).fontColor('#182431').textAlign(TextAlign.Start)
- }.width(244).height(48)
- }, item => item.toString())
- }.padding({ left: 24, top: 8 })
- // 使用縱向分割線場景
- Text('Vertical divider').fontSize(9).fontColor(0xCCCCCC)
- Column() {
- Column() {
- Row().width(288).height(64).backgroundColor('#30C9F0').opacity(0.3)
- Row() {
- Button('Button')
- .width(136)
- .height(22)
- .fontSize(16)
- .fontColor('#007DFF')
- .fontWeight(500)
- .backgroundColor(Color.Transparent)
- Divider().vertical(true).height(22).color('#182431').opacity(0.6).margin({ left: 8, right: 8 })
- Button('Button')
- .width(136)
- .height(22)
- .fontSize(16)
- .fontColor('#007DFF')
- .fontWeight(500)
- .backgroundColor(Color.Transparent)
- }.margin({ top: 17 })
- }
- .width(336)
- .height(152)
- .backgroundColor('#FFFFFF')
- .borderRadius(24)
- .padding(24)
- }
- .width('100%')
- .height(168)
- .backgroundColor('#F1F3F5')
- .justifyContent(FlexAlign.Center)
- .margin({ top: 8 })
- }.width('100%').padding({ top: 24 })
- }
- }
Copyright©2021 w3cschool編程獅|閩ICP備15016281號-3|閩公網(wǎng)安備35020302033924號
違法和不良信息舉報電話:173-0602-2364|舉報郵箱:jubao@eeedong.com
掃描二維碼
下載編程獅App
編程獅公眾號
聯(lián)系方式:
更多建議: