当前位置:网站首页>【ARK UI】HarmonyOS ETS的引导页的实现
【ARK UI】HarmonyOS ETS的引导页的实现
2022-08-10 17:45:00 【华为开发者论坛】
参考资料
代码实现
1、准备资料,准备三个引导图片
2、绘画ETS的布局
新建一个WelcomePage的page界面,在改ETS文件添加引导页和启动按钮,具体注释事件,代码如下
import router from '@system.router';@[email protected] WelcomePage { private swiperController: SwiperController = new SwiperController()/** * 控制启动按钮显示还是隐藏 */ @State flag:boolean=false; build() { Column({ space: 5 }) { Stack({ alignContent: Alignment.TopEnd }) { Swiper(this.swiperController) { //todo 引导页图片内容 //todo 引导页一 Stack({ alignContent: Alignment.Center }){ Image($r("app.media.icon")).width(100).height(100) Text("引导页一").fontSize(20).fontColor(Color.White).margin({top:150}) }.width('100%').height("100%").backgroundColor(Color.Red).align(Alignment.Center) //todo 引导页 二 Stack({ alignContent: Alignment.Center }){ Image($r("app.media.icon")).width(100).height(100) Text("引导页二").fontSize(20).fontColor(Color.White).margin({top:150}) }.width('100%').height("100%").backgroundColor(Color.Orange).align(Alignment.Center) //todo 引导页三 Stack({ alignContent: Alignment.Center }){ Image($r("app.media.icon")).width(100).height(100) Text("引导页三").fontSize(20).fontColor(Color.White).margin({top:150}) }.width('100%').height("100%").backgroundColor(Color.Green).align(Alignment.Center) } .index(0)//todo 当前索引为0 开始 .autoPlay(false)//todo 停止自动播放 .indicator(true) // todo 默认开启指示点 .loop(false) // todo 停止自动播放 默认开启循环播放 .vertical(false) //todo 横向切换 默认横向切换 .onChange((index: number) => { /** * 根据Index 进行判断 当引导页播放到最后一个页面时候 * 让启动按钮显示 否则的话 不显示 */ if(index==2){//todo 最后一个 设置flag 为true this.flag=true }else{//todo 不是最后一个 设置flag为false this.flag=false } }) if(this.flag)//todo 当flag 为true 则显示启动按钮 为false的时候不显示 Text('启动').width('300px').height('150px') .textAlign(TextAlign.Center).fontSize(20) .backgroundColor(Color.White) .margin({right:20,top:20}) .onClick(function(){//todo 实现按钮点击事件 进入到主界面 router.push({ uri:"pages/index" }) }) } } }}
运行效果
欲了解更多更全技术文章,欢迎访问https://developer.huawei.com/consumer/cn/forum/?ha_source=zzh
边栏推荐
- R语言创建列表数据(list):根据名称索引列表元素、双方括号访问单个元素、单方括号访问子列表
- requires ‘angle‘ attribute to be a multiple of 45
- Kong自定义插件初体验
- JNDI and RMI, LDAP
- Mysql index, transaction and storage engine
- 一小时搞定 简单VBA编程 Excel宏编程快速扫盲
- 产品-Axure9英文版,A页面内a1状态跳转B页面的b2状态,(条件跳转状态)
- 实用工具在线网站
- 五菱宏光MINI EV,唯一的缺点就是安全性
- 1001 A+B Format (string processing)
猜你喜欢
H3C_堆叠(IRF)及链路聚合在项目中的综合应用
烟雾、空气质量、温湿度…自己徒手做个环境检测设备
mysql主主复制+keepalived高可用
烟雾、空气质量、温湿度…自己徒手做个环境检测设备
【图像分割】基于元胞自动机实现图像分割附matlab代码
WebRTC source code analysis nack detailed explanation
【2011】【论文笔记】用THz-TDS观察水树——
Making Pre-trained Language Models Better Few-Shot Learners
Toronto Research Chemicals萜烯分析丨(+)-柠檬烯
const的自己理解
随机推荐
WebRTC源码分析 nack详解
【接入指南 之 直接接入】手把手教你快速上手接入HONOR Connect平台(下)
DASCTF2022.07 empowerment competition WEB topic recurrence
FFmpeg extract H264 nalu from the mp4
eager模式和graph模式 Tensorflow
不止跑路,拯救误操作rm -rf /*的小伙儿
Flexsim 发生器和暂存区设定临时实体流颜色和端口
BalsnCTF2021
海思HI3516DV300开发资料
【图像分割】基于元胞自动机实现图像分割附matlab代码
五菱宏光MINI EV,唯一的缺点就是安全性
CDH6.3.2之Kerberos安全认证_大数据培训
HDLBits: 在线学习 SystemVerilog(零)-在线“巡礼” HDLBits
R语言patchwork包将多个可视化结果组合起来、plot_annotation函数以及tag_level参数将组合图用大写字母进行顺序编码、为组合图的标签添加自定义后缀信息(suffix)
WebRTC source code analysis nack detailed explanation
Toronto Research Chemicals萜烯分析丨(+)-柠檬烯
【严重】Nps 鉴权绕过 0day 漏洞
期货开户手续费加1分已经是常态
Talking about Taishan crowdfunding system development technical description and dapp chain crowdfunding system development analysis
装饰者模式