当前位置:网站首页>【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
边栏推荐
- 华为云连续5年保持中国政务云基础设施市场份额第一…
- Wuling Hongguang MINI EV, the only drawback is safety
- R语言拟合ARIMA模型:使用forecast包中的auto.arima函数自动搜索最佳参数组合、模型阶数(p,d,q)、如果已知阶数则直接使用arima函数构建模型(order参数指定阶数)
- Toronto Research Chemicals农药检测丨甲硫威
- ZLMediaKit 服务器源码解读---RTSP推流拉流
- HDLBits: 在线学习 SystemVerilog(零)-在线“巡礼” HDLBits
- 海思HI3516DV300开发资料
- 本周四晚19:00知识赋能第六期第5课丨OpenHarmony WiFi子系统
- 【燃】是时候展现真正的实力了!一文看懂2022华为开发者大赛技术亮点
- R语言使用ggpubr包的ggbarplot函数可视化柱状图、设置add参数为mean_se和jitter可视化不同水平均值的柱状图并为柱状图添加误差线(se标准误差)和抖动数据点分布
猜你喜欢
随机推荐
WebRTC源码分析 nack详解
FlexSim仿真软件入门笔记:基本操作、快捷键
基于AWS构建云上数仓第二步:AWS常见服务简介
Wuling Hongguang MINI EV, the only drawback is safety
Making Pre-trained Language Models Better Few-Shot Learners
软链接、硬链接——ln -s 使用
【独立站运营】做社交媒体营销的两大关键点
requires ‘angle‘ attribute to be a multiple of 45
【燃】是时候展现真正的实力了!一文看懂2022华为开发者大赛技术亮点
R语言创建列表数据(list):根据名称索引列表元素、双方括号访问单个元素、单方括号访问子列表
自动化测试 RobotFramework安装以及使用教程
烟雾、空气质量、温湿度…自己徒手做个环境检测设备
FFmpeg extract H264 nalu from the mp4
[JMeter]Beanshell解析Json格式的接口响应数据
机器人控制器编程整理汇总-辞旧迎新-
LeetCode 198:打家劫舍
Xilinx FPGA收发器参考时钟设计应用
Oracle Install [email protected] 7.6
本周四晚19:00知识赋能第六期第5课丨OpenHarmony WiFi子系统
五菱宏光MINI EV,唯一的缺点就是安全性