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

相关推荐
anyup12 小时前
来简单聊聊鸿蒙开发,万元奖金的事~
前端·华为·harmonyos
Georgewu13 小时前
【无测试机别害怕】华为云鸿蒙云手机南:从零到联调全流程详解
harmonyos
Georgewu1 天前
【HarmonyOS 7】DevEco Code安装与使用
harmonyos
Georgewu1 天前
【HarmonyOS 7】鸿蒙应用开发如何屏蔽剪切板
harmonyos
谷子在生长2 天前
纯血鸿蒙自定义弹窗最佳实践:从「到处复制」到「一行调用」
前端·harmonyos
小魔女千千鱼3 天前
把 Go 塞进鸿蒙PC:windows上用 c-shared 跑 2048
harmonyos
TrisighT3 天前
Electron 跑在鸿蒙 PC 上,单窗口和多窗口内存差 800MB?我抓了 5 组数据
性能优化·electron·harmonyos
TrisighT3 天前
AI写埋点代码,35%覆盖率坑惨运营
harmonyos·arkts·arkui
Junerver7 天前
把 DevEco Code 的 HarmonyOS 开发能力装进口袋——harmonyos-dev-skill
harmonyos