HarmonyOS/OpenHarmony原生应用-ArkTS万能卡片组件Stack

堆叠容器,子组件按照顺序依次入栈,后一个子组件覆盖前一个子组件。该组件从API Version 7开始支持。可以包含子组件。

一、接口

Stack(value?: { alignContent?: Alignment })

从API version 9开始,该接口支持在ArkTS卡片中使用。

二、属性

除支持通用属性外,还支持以下属性:

三、示例

复制代码
// xxx.ets
@Entry
@Component
struct StackExample {
  build() {
    Stack({ alignContent: Alignment.Bottom }) {
      Text('First child, show in bottom').width('90%').height('100%').backgroundColor(0xd2cab3).align(Alignment.Top)
      Text('Second child, show in top').width('70%').height('60%').backgroundColor(0xc1cbac).align(Alignment.Top)
    }.width('100%').height(150).margin({ top: 5 })
  }
}

四、效果展示

五、场景

卡片上实现堆叠的场景使用。

本文根据HarmonyOS官方文档整理。


©著作权归作者所有:来自51CTO博客作者鸿蒙时代的原创作品,请联系作者获取转载授权,否则将追究法律责任

HarmonyOS/OpenHarmony原生应用-ArkTS万能卡片组件Stack

https://blog.51cto.com/u_14946066/7773837

相关推荐
JaneConan几秒前
鸿蒙 韶非 UI 系列:能力调用 startAbilityForResult,跳能力拿回参,鸿蒙能力路由入门
后端·harmonyos
FrameNotWork1 小时前
HarmonyOS 6.0 文件加密与安全存储:从哈希到硬件级密钥管理全链路实战
安全·哈希算法·harmonyos
Georgewu2 小时前
【HarmonyOS AI】鸿蒙开发者需要搞懂的 AI Coding 概念
harmonyos
FF2501_940228582 小时前
HarmonyOS开发实战:小分享-App项目架构全景解析
后端·华为·harmonyos·鸿蒙
解局易否结局2 小时前
鸿蒙原生开发实战:Native 图片处理与二维码全链路解析
华为·harmonyos
<小智>4 小时前
鸿蒙多功能工具箱开发实战(十二)-二十四节气与黄历数据展示
ui·华为·harmonyos
Georgewu4 小时前
【HarmonyOS AI】DevEco CLI、Skills、知识库运用AI Coding提效详解
harmonyos
2501_919749035 小时前
华为鸿蒙免费听歌APP+免费铃声APP
华为·harmonyos
爱写代码的森5 小时前
鸿蒙三方库 | harmony-utils之CrashUtil全局异常捕获详解
华为·harmonyos·鸿蒙·huawei
tsqtsqtsq03096 小时前
ArkTS 泛型概念详解
华为·harmonyos·鸿蒙系统