【鸿蒙学习笔记】位置设置

官方文档:位置设置

目录标题

align:子元素的对齐方式

cpp 复制代码
Stack() {Text('TopStart')}.width('90%').height(50).backgroundColor(0xFFE4C4).align(Alignment.TopStart)
Stack() {Text('Top')}.width('90%').height(50).backgroundColor(0xFFE4C4).align(Alignment.Top)
Stack() {Text('TopEnd')}.width('90%').height(50).backgroundColor(0xFFE4C4).align(Alignment.TopEnd)
Stack() {Text('Start')}.width('90%').height(50).backgroundColor(0xFFE4C4).align(Alignment.Start)
Stack() {Text('Center')}.width('90%').height(50).backgroundColor(0xFFE4C4).align(Alignment.Center)
Stack() {Text('End')}.width('90%').height(50).backgroundColor(0xFFE4C4).align(Alignment.End)
Stack() {Text('BottomStart')}.width('90%').height(50).backgroundColor(0xFFE4C4).align(Alignment.BottomStart)
Stack() {Text('Bottom')}.width('90%').height(50).backgroundColor(0xFFE4C4).align(Alignment.Bottom)
Stack() {Text('BottomEnd')}.width('90%').height(50).backgroundColor(0xFFE4C4).align(Alignment.BottomEnd)

direction:官方文档没懂,看图理解吧

cpp 复制代码
Row() {
  Text('1').height(50).width('25%').fontSize(16).backgroundColor(0xF5DEB3).textAlign(TextAlign.Center)
  Text('2').height(50).width('25%').fontSize(16).backgroundColor(0xD2B48C).textAlign(TextAlign.Center)
  Text('3').height(50).width('25%').fontSize(16).backgroundColor(0xF5DEB3).textAlign(TextAlign.Center)
  Text('4').height(50).width('25%').fontSize(16).backgroundColor(0xD2B48C).textAlign(TextAlign.Center)
}.width('90%').direction(Direction.Ltr)
Row() {
  Text('1').height(50).width('25%').fontSize(16).backgroundColor(0xF5DEB3).textAlign(TextAlign.Center)
  Text('2').height(50).width('25%').fontSize(16).backgroundColor(0xD2B48C).textAlign(TextAlign.Center)
  Text('3').height(50).width('25%').fontSize(16).backgroundColor(0xF5DEB3).textAlign(TextAlign.Center)
  Text('4').height(50).width('25%').fontSize(16).backgroundColor(0xD2B48C).textAlign(TextAlign.Center)
}.width('90%').direction(Direction.Rtl)
Row() {
  Text('1').height(50).width('25%').fontSize(16).backgroundColor(0xF5DEB3).textAlign(TextAlign.Center)
  Text('2').height(50).width('25%').fontSize(16).backgroundColor(0xD2B48C).textAlign(TextAlign.Center)
  Text('3').height(50).width('25%').fontSize(16).backgroundColor(0xF5DEB3).textAlign(TextAlign.Center)
  Text('4').height(50).width('25%').fontSize(16).backgroundColor(0xD2B48C).textAlign(TextAlign.Center)
}.width('90%').direction(Direction.Auto)
相关推荐
山川而川-R12 小时前
RK3588边缘计算:YOLOv8 使用Android NDK部署_笔记1
人工智能·笔记·yolo·安卓
饮水桶_T14 小时前
C++ stack & queue复习笔记
开发语言·笔记·算法
叼烟扛炮16 小时前
[LangChain] 学习笔记(026):模型根本没有记忆——「多轮对话」是你每次把历史重发一遍
笔记·学习·langchain
钉先生贾17 小时前
HarmonyOS 7.0 多设备协同实战 35:用户撤销分享链接后,怎样使缓存入口同时失效
缓存·华为·harmonyos
饮水桶_T17 小时前
HashMap笔记
开发语言·数据结构·笔记
星恒随风19 小时前
从0实现C++ AI大模型接入SDK(三):环境搭建与ChatSDK快速上手——实现我们的第一个AI聊天程序
linux·开发语言·c++·人工智能·笔记
MSTcheng.21 小时前
【LinuxIO篇】Linux学习第二十三弹——fopen和open有什么区别?从 FILE* 到 fd,讲透 Linux 文件 IO
linux·运维·学习·io·系统调用·fd
Z21-X1 天前
云原生运维学习笔记:Kubernetes Service 发现、类型与 kube-proxy 实战
运维·笔记·学习·云原生·kubernetes
sealaugh321 天前
powerbi学习笔记(day2)powerbi进阶
笔记·学习·powerbi
一只大鸽子1 天前
游戏开发笔记11-Godot RPG游戏基础-优化-四方向攻击
笔记·游戏·godot