鸿蒙HarmonyOS实战-Stage模型(开发卡片页面)
1.鸿蒙HarmonyOS实战-ArkTS语言(基本语法)2.鸿蒙HarmonyOS实战-ArkTS语言(状态管理)3.鸿蒙HarmonyOS实战-ArkTS语言(渲染控制)4.鸿蒙HarmonyOS实战-ArkUI组件(Row/Column)5.鸿蒙HarmonyOS实战-ArkUI组件(Stack)6.鸿蒙HarmonyOS实战-ArkUI组件(Flex)7.鸿蒙HarmonyOS实战-ArkUI组件(RelativeContainer)8.鸿蒙HarmonyOS实战-ArkUI组件(GridRow/GridCol)9.鸿蒙HarmonyOS实战-ArkUI组件(mediaquery)10.鸿蒙HarmonyOS实战-ArkUI组件(List)11.鸿蒙HarmonyOS实战-ArkUI组件(Grid/GridItem)12.鸿蒙HarmonyOS实战-ArkUI组件(Swiper)13.鸿蒙HarmonyOS实战-ArkUI组件(Button)14.鸿蒙HarmonyOS实战-ArkUI组件(Radio)15.鸿蒙HarmonyOS实战-ArkUI组件(Toggle)16.鸿蒙HarmonyOS实战-ArkUI组件(Progress)17.鸿蒙HarmonyOS实战-ArkUI组件(Text/Span)18.鸿蒙HarmonyOS实战-ArkUI组件(TextInput/TextArea)19.鸿蒙HarmonyOS实战-ArkUI组件(CustomDialog)20.鸿蒙HarmonyOS实战-ArkUI组件(Video)21.鸿蒙HarmonyOS实战-ArkUI组件(Popup)22.鸿蒙HarmonyOS实战-ArkUI组件(Menu)23.鸿蒙HarmonyOS实战-ArkUI组件(页面路由)24.鸿蒙HarmonyOS实战-ArkUI组件(Navigation)25.鸿蒙HarmonyOS实战-ArkUI组件(Tabs)26.鸿蒙HarmonyOS实战-ArkUI组件(Image)27.鸿蒙HarmonyOS实战-ArkUI组件(Shape)28.鸿蒙HarmonyOS实战-ArkUI组件(Canvas)29.鸿蒙HarmonyOS实战-ArkUI动画(布局更新动画)30.鸿蒙HarmonyO实战-ArkUI动画(组件内转场动画)31.鸿蒙HarmonyOS实战-ArkUI动画(放大缩小视图)32.鸿蒙HarmonyOS实战-ArkUI动画(页面转场动画)33.鸿蒙HarmonyOS实战-ArkUI事件(触屏事件)34.鸿蒙HarmonyOS实战-ArkUI事件(键鼠事件)35.鸿蒙HarmonyOS实战-ArkUI事件(焦点事件)36.鸿蒙HarmonyOS实战-ArkUI事件(手势方法)37.鸿蒙HarmonyOS实战-ArkUI事件(单一手势)38.鸿蒙HarmonyOS实战-ArkUI事件(组合手势)39.鸿蒙HarmonyOS实战-Stage模型(概述和组件配置)40.鸿蒙HarmonyOS实战-Stage模型(UIAbility组件)41.鸿蒙HarmonyOS实战-Stage模型(ExtensionAbility组件)42.鸿蒙HarmonyOS实战-Stage模型(服务卡片介绍和运行机制)43.鸿蒙HarmonyOS实战-Stage模型(服务卡片的模块和创建)
44.鸿蒙HarmonyOS实战-Stage模型(开发卡片页面)
45.鸿蒙HarmonyOS实战-Stage模型(开发卡片事件)46.鸿蒙HarmonyOS实战-Stage模型(卡片数据交互)47.鸿蒙HarmonyOS实战-Stage模型(AbilityStage组件容器)48.鸿蒙HarmonyOS实战-Stage模型(应用上下文Context)49.鸿蒙HarmonyOS实战-Stage模型(信息传递载体Want)50.鸿蒙HarmonyOS实战-Stage模型(进程模型)51.鸿蒙HarmonyOS实战-Stage模型(线程模型)52.鸿蒙HarmonyOS实战-Web组件(基本使用和属性)53.鸿蒙HarmonyOS实战-Web组件(前端函数和应用侧函数相互调用)54.鸿蒙HarmonyOS实战-Web组件(页面跳转和浏览记录)55.鸿蒙HarmonyOS实战-Web组件(Cookie及数据存储)56.鸿蒙HarmonyOS实战-Web组件(请求响应和页面调试)57.鸿蒙HarmonyOS实战-ArkTS语言基础类库(概述)58.鸿蒙HarmonyOS实战-ArkTS语言基础类库(并发)59.鸿蒙HarmonyOS实战-ArkTS语言基础类库(容器类库)60.鸿蒙HarmonyOS实战-ArkTS语言基础类库(XML)61.鸿蒙HarmonyOS实战-ArkTS语言基础类库(通知)62.鸿蒙HarmonyOS实战-窗口管理🚀一、开发卡片页面
HarmonyOS元服务卡片页面(Metaservice Card Page)是指在HarmonyOS系统中,用于展示元服务的页面界面。元服务是指一组提供特定功能或服务的组件,例如天气服务、音乐播放服务等。元服务卡片页面可以显示元服务的相关信息和操作选项,用户可以通过点击卡片页面上的按钮或交互元素来使用相关的元服务功能。元服务卡片页面提供了一种快速访问和使用元服务的方式,方便用户进行各种操作和任务。
🔎1.卡片页面能力说明
支持在卡片中使用的ArkTS能力:
🔎2.卡片使用动效能力
@Entry
@Component
struct AttrAnimationExample {
@State rotateAngle: number = 0;
build() {
Column() {
Button('change rotate angle')
.onClick(() => {
this.rotateAngle = 90;
})
.margin(50)
.rotate({ angle: this.rotateAngle })
.animation({
curve: Curve.EaseOut,
playMode: PlayMode.AlternateReverse
})
}.width('100%').margin({ top: 20 })
}
}
🔎3.卡片使用自定义绘制能力
@Entry
@Component
struct Card {
private canvasWidth: number = 0;
private canvasHeight: number = 0;
// 初始化CanvasRenderingContext2D和RenderingContextSettings
private settings: RenderingContextSettings = new RenderingContextSettings(true);
private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings);
build() {
Column() {
Row() {
Canvas(this.context)
.margin('5%')
.width('90%')
.height('90%')
.onReady(() => {
console.info('[ArkTSCard] onReady for canvas draw content');
// 在onReady回调中获取画布的实际宽和高
this.canvasWidth = this.context.width;
this.canvasHeight = this.context.height;
// 绘制画布的背景
this.context.fillStyle = 'rgba(203, 154, 126, 1.00)';
this.context.fillRect(0, 0, this.canvasWidth, this.canvasHeight);
// 在画布的中心绘制一个红色的圆
this.context.beginPath();
let radius = this.context.width / 3
let circleX = this.context.width / 2
let circleY = this.context.height / 2
this.context.moveTo(circleX - radius, circleY);
this.context.arc(circleX, circleY, radius, 2 * Math.PI, 0, true);
this.context.closePath();
this.context.fillStyle = 'red';
this.context.fill();
// 绘制笑脸的左眼
let leftR = radius / 4
let leftX = circleX - (radius / 2)
let leftY = circleY - (radius / 3.5)
this.context.beginPath();
this.context.arc(leftX, leftY, leftR, 0, Math.PI, true);
this.context.strokeStyle = '#ffff00'
this.context.lineWidth = 10
this.context.stroke()
// 绘制笑脸的右眼
let rightR = radius / 4
let rightX = circleX + (radius / 2)
let rightY = circleY - (radius / 3.5)
this.context.beginPath();
this.context.arc(rightX, rightY, rightR, 0, Math.PI, true);
this.context.strokeStyle = '#ffff00'
this.context.lineWidth = 10
this.context.stroke()
// 绘制笑脸的嘴巴
let mouthR = radius / 2.5
let mouthX = circleX
let mouthY = circleY + (radius / 3)
this.context.beginPath();
this.context.arc(mouthX, mouthY, mouthR, Math.PI, 0, true);
this.context.strokeStyle = '#ffff00'
this.context.lineWidth = 10
this.context.stroke()
})
}
}.height('100%').width('100%')
}
}
🚀写在最后
- 如果你觉得这篇内容对你还蛮有帮助,我想邀请你帮我三个小忙:
- 点赞,转发,有你们的 『点赞和评论』,才是我创造的动力。
- 关注小编,同时可以期待后续文章ing🚀,不定期分享原创知识。
- 更多鸿蒙最新技术知识点,请关注作者博客:https://t.doruo.cn/14DjR1rEY
合集:
鸿蒙入门实战全套(核心知识点)
分类:
鸿蒙HarmonyOS
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】博客园社区专享云产品让利特惠,阿里云新客6.5折上折
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 【.NET】调用本地 Deepseek 模型
· CSnakes vs Python.NET:高效嵌入与灵活互通的跨语言方案对比
· DeepSeek “源神”启动!「GitHub 热点速览」
· 我与微信审核的“相爱相杀”看个人小程序副业
· Plotly.NET 一个为 .NET 打造的强大开源交互式图表库