W3Cschool
恭喜您成為首批注冊用戶
獲得88經(jīng)驗值獎勵
設(shè)置組件邊框樣式。
從API Version 7開始支持。后續(xù)版本如有新增內(nèi)容,則采用上角標(biāo)單獨(dú)標(biāo)記該內(nèi)容的起始版本。
從API Version 9開始,父節(jié)點(diǎn)的border顯示在子節(jié)點(diǎn)內(nèi)容之上。
名稱 | 參數(shù)類型 | 描述 |
---|---|---|
border | { width?: Length | EdgeWidths9+, color?: ResourceColor | EdgeColors9+, radius?: Length | BorderRadiuses9+, style?: BorderStyle | EdgeStyles9+ } | 統(tǒng)一邊框樣式設(shè)置接口。 - width:設(shè)置邊框?qū)挾取?/p> - color:設(shè)置邊框顏色。 - radius:設(shè)置邊框圓角半徑。 - style:設(shè)置邊框樣式。 說明: 邊框?qū)挾饶J(rèn)值為0,即不顯示邊框。 |
borderStyle | 設(shè)置元素的邊框樣式。 默認(rèn)值:BorderStyle.Solid 從API version 9開始,該接口支持在ArkTS卡片中使用 ,卡片中僅支持設(shè)置相同的邊框樣式。 | |
borderWidth | Length | EdgeWidths9+ | 設(shè)置元素的邊框?qū)挾?,不支持百分比?/p> 從API version 9開始,該接口支持在ArkTS卡片中使用 ,卡片中僅支持設(shè)置相同的邊框?qū)挾取?/p> |
borderColor | 設(shè)置元素的邊框顏色。 默認(rèn)值:Color.Black 從API version 9開始,該接口支持在ArkTS卡片中使用,卡片中僅支持設(shè)置相同的邊框顏色。 | |
borderRadius | Length | BorderRadiuses9+ | 設(shè)置元素的邊框圓角半徑,不支持百分比。 從API version 9開始,該接口支持在ArkTS卡片中使用,卡片中僅支持設(shè)置相同的邊框圓角半徑。 |
引入該對象時,至少傳入一個參數(shù)。
名稱 | 參數(shù)類型 | 必填 | 描述 |
---|---|---|---|
left | 否 | 左側(cè)邊框顏色。 | |
right | 否 | 右側(cè)邊框顏色。 | |
top | 否 | 上側(cè)邊框顏色。 | |
bottom | 否 | 下側(cè)邊框顏色。 |
引入該對象時,至少傳入一個參數(shù)。
名稱 | 參數(shù)類型 | 必填 | 描述 |
---|---|---|---|
left | 否 | 左側(cè)邊框樣式。 | |
right | 否 | 右側(cè)邊框樣式。 | |
top | 否 | 上側(cè)邊框樣式。 | |
bottom | 否 | 下側(cè)邊框樣式。 |
- // xxx.ets
- @Entry
- @Component
- struct BorderExample {
- build() {
- Column() {
- Flex({ justifyContent: FlexAlign.SpaceAround, alignItems: ItemAlign.Center }) {
- // 線段
- Text('dashed')
- .borderStyle(BorderStyle.Dashed).borderWidth(5).borderColor(0xAFEEEE).borderRadius(10)
- .width(120).height(120).textAlign(TextAlign.Center).fontSize(16)
- // 點(diǎn)線
- Text('dotted')
- .border({ width: 5, color: 0x317AF7, radius: 10, style: BorderStyle.Dotted })
- .width(120).height(120).textAlign(TextAlign.Center).fontSize(16)
- }.width('100%').height(150)
- Text('.border')
- .fontSize(50)
- .width(300)
- .height(300)
- .border({
- width: { left: '5lpx', right: '10lpx', top: '20lpx', bottom: '30lpx' },
- color: { left: '#e3bbbb', right: Color.Blue, top: Color.Red, bottom: Color.Green },
- radius: { topLeft: 10, topRight: 20, bottomLeft: 40, bottomRight: 80 },
- style: {
- left: BorderStyle.Dotted,
- right: BorderStyle.Dotted,
- top: BorderStyle.Solid,
- bottom: BorderStyle.Dashed
- }
- }).textAlign(TextAlign.Center)
- }
- }
- }
Copyright©2021 w3cschool編程獅|閩ICP備15016281號-3|閩公網(wǎng)安備35020302033924號
違法和不良信息舉報電話:173-0602-2364|舉報郵箱:jubao@eeedong.com
掃描二維碼
下載編程獅App
編程獅公眾號
聯(lián)系方式:
更多建議: