成人免费xxxxx在线视频软件_久久精品久久久_亚洲国产精品久久久_天天色天天色_亚洲人成一区_欧美一级欧美三级在线观看

彈性布局組件Flex—學習筆記之一

原創
系統 OpenHarmony
一次開發多端部署,我理解是設計一個彈性UI框架。容器組件Flex從API version 7開始支持,它是彈性布局組件,這次就Flex的不同參數來作個簡單的demo。

??想了解更多內容,請訪問:??

??51CTO和華為官方合作共建的鴻蒙技術社區??

??https://harmonyos.51cto.com??

前言

一次開發多端部署,我理解是設計一個彈性UI框架。容器組件Flex從API version 7開始支持,它是彈性布局組件,這次就Flex的不同參數來作個簡單的demo,一起來學習吧(? ?_?)?

概述

Flex有五類參數,本篇先講direction和wrap

效果圖如下:

正文

1、新建空工程

左上角File -> New -> New Project -> Empty Ability,language選擇ets

2、新建ets page

本次案例會在example1和example2上寫

3、FlexDirection的Demo

Row為行方向,Column為列方向;行方向的,設置四個文本組件,每個的寬度均為容器Flex的寬度的20%,則會預留一個20%寬的空位,通過效果圖可見Row是從左至右,RowReverse是從右至左;而Column是從上至下,ColumnReverse是從下至上

代碼如下:

// Example 01
@Entry
@Component
struct FlexExample1 {
build() {
Column({ space: 5 }) {
DirectionRowFlex({text:'direction:Row',direction:FlexDirection.Row})
DirectionRowFlex({text:'direction:RowReverse',direction:FlexDirection.RowReverse})
DirectionColumnFlex({text:'direction:Column',direction:FlexDirection.Column})
DirectionColumnFlex({text:'direction:ColumnReverse',direction:FlexDirection.ColumnReverse})
}.width('100%')
}
}

@Component
struct DirectionRowFlex{
private text:string
private direction:FlexDirection
build() {
Column({ space: 5 }) {
Text(this.text).fontSize(15).width('90%')
Flex({ direction:this.direction }) {
Text('1').fontSize(30).width('20%').height(50).backgroundColor(0xF5DEB3)
Text('2').fontSize(30).width('20%').height(50).backgroundColor(0xD2B48C)
Text('3').fontSize(30).width('20%').height(50).backgroundColor(0xF5DEB3)
Text('4').fontSize(30).width('20%').height(50).backgroundColor(0xD2B48C)
}
.height(70)
.width('90%')
.padding(10)
.backgroundColor(0xAFEEEE)
}.width('100%').margin({ top: 5 })
}
}

@Component
struct DirectionColumnFlex{
private text:string
private direction:FlexDirection
build() {
Column({ space: 5 }) {
Text(this.text).fontSize(15).width('90%')
Flex({ direction:this.direction }) {
Text('1').fontSize(18).width('100%').height(40).backgroundColor(0xF5DEB3)
Text('2').fontSize(18).width('100%').height(40).backgroundColor(0xD2B48C)
Text('3').fontSize(18).width('100%').height(40).backgroundColor(0xF5DEB3)
Text('4').fontSize(18).width('100%').height(40).backgroundColor(0xD2B48C)
}
.height(160)
.width('90%')
.padding(10)
.backgroundColor(0xAFEEEE)
}.width('100%').margin({ top: 5 })
}
}

4、FlexWrap的Demo

同樣定義的Text組件在Wrap和NoWrap下的布局效果不一樣,在允許多行排布的Wrap(direction默認Row),單個Text組件的寬度如設置一般,為容器組件的寬度的50%;而在NoWrap單行排布,3個50%會超出100%,因此顯示的排布為三個的占比,即50%/50%+50%+50%。WrapReverse為Wrap的反向,即為多行/列排布,方向為從右至左/從下至上

代碼如下:

// Example 02
@Entry
@Component
struct FlexExample2 {
build() {
Column({ space: 5 }) {
WrapFlex({text:'wrap:Wrap',wrap:FlexWrap.Wrap})
WrapFlex({text:'wrap:NoWrap',wrap:FlexWrap.NoWrap})
Text('wrap:WrapReverse,direction:Row').fontSize(15).width('90%')
Flex({ wrap: FlexWrap.WrapReverse,direction:FlexDirection.Row}) {
Text('1').fontSize(20).width('50%').height(50).backgroundColor(0xF5DEB3)
Text('2').fontSize(20).width('50%').height(50).backgroundColor(0xFFBC79)
Text('3').fontSize(20).width('50%').height(50).backgroundColor(0xD2B48C)
}
.height(120)
.width('90%')
.padding(10)
.backgroundColor(0xAFEEEE)

}.width('100%')
}
}

@Component
struct WrapFlex{
private text:string
private wrap:FlexWrap
build(){
Column({ space: 5 }) {
Text(this.text).fontSize(15).width('90%')
Flex({ wrap:this.wrap}) {
Text('1').fontSize(20).width('50%').height(50).backgroundColor(0xF5DEB3)
Text('2').fontSize(20).width('50%').height(50).backgroundColor(0xFFBC79)
Text('3').fontSize(20).width('50%').height(50).backgroundColor(0xD2B48C)
}
.width('90%')
.padding(10)
.backgroundColor(0xAFEEEE)

}.width('100%').margin({ top: 5 })
}
}

結語

以上就是我這次的小分享啦??!!2022,學習路上繼續前進!

??想了解更多內容,請訪問:??

??51CTO和華為官方合作共建的鴻蒙技術社區??

??https://harmonyos.51cto.com??

責任編輯:jianghua 來源: 鴻蒙社區
相關推薦

2022-02-17 20:07:45

Flex鴻蒙Flex組件

2010-07-27 10:39:25

Flex組件

2010-08-05 13:27:06

Flex布局

2010-08-05 10:29:11

Flex效果

2010-07-30 13:52:17

Flex組件

2010-08-09 10:34:05

Flex背景

2010-08-05 15:46:13

Flex行為Flex效果

2010-07-29 13:18:45

Flex右鍵菜單

2010-07-29 15:36:23

Flex安全沙箱

2010-08-04 09:26:27

Flex數據

2010-08-10 16:41:54

FlexJSP

2010-08-11 15:35:47

Flex DataGr

2017-03-16 08:46:43

TensorFlow安裝入門

2010-07-27 15:49:28

Flex

2010-08-12 11:05:33

Flex數據綁定

2010-08-09 15:19:29

Flex滾動條

2010-07-30 14:50:38

Flex項目

2010-07-28 12:47:06

Flex組件

2010-08-06 11:04:06

Flex模塊化

2010-08-10 15:26:38

Flex應用程序
點贊
收藏

51CTO技術棧公眾號

主站蜘蛛池模板: 1级毛片 | 老外几下就让我高潮了 | 天天操天天拍 | 久久国产激情视频 | 久久一二三区 | 黄色骚片| 国产成人精品免费视频大全最热 | 日本一级淫片免费啪啪3 | 在线免费观看成人 | 婷婷狠狠 | 日韩欧美在线不卡 | 久久久激情视频 | 国产亚洲精品久久19p | 嫩草影院网址 | 视频在线日韩 | 在线观看免费毛片 | 久久1区 | 黄频免费 | 国产精品av久久久久久久久久 | 成人性视频免费网站 | 欧美综合在线视频 | 亚洲aⅴ精品| 久草网在线视频 | 国产一区二区在线免费播放 | 久久中文字幕一区 | 亚洲视频观看 | 免费观看国产视频在线 | 亚洲精品视频网站在线观看 | 日韩在线xx | 一区二区国产在线 | 99久久婷婷国产精品综合 | 久久com| 精品国产1区2区3区 在线国产视频 | 91av在线视频观看 | 国产精品高潮呻吟久久 | 蜜桃av一区二区三区 | 欧美国产日韩一区二区三区 | 久久专区 | 久久精品色欧美aⅴ一区二区 | 亚洲国产成人精品一区二区 | 亚洲精品乱码久久久久久按摩 |