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

官方文档:位置设置

目录标题

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)
相关推荐
tswowo61 天前
Markdown笔记
笔记
独特的螺狮粉1 天前
开源鸿蒙跨平台Flutter开发:手机清理小助手应用
开发语言·flutter·游戏·智能手机·开源·harmonyos·鸿蒙
李李李勃谦1 天前
Flutter 框架跨平台鸿蒙开发 - 儿童故事库
flutter·华为·harmonyos
2301_822703201 天前
Flutter 框架跨平台鸿蒙开发 - 梦境场景重现应用
flutter·华为·信息可视化·开源·harmonyos·鸿蒙
Shadow(⊙o⊙)1 天前
C语言学习中需要的额外函数
c语言·开发语言·学习
提子拌饭1331 天前
浅灰计算器:鸿蒙的Flutter框架 实现的简洁计算器应用
flutter·华为·harmonyos·鸿蒙
艾莉丝努力练剑1 天前
【Linux线程】Linux系统多线程(四):线程ID及进程地址空间布局,线程封装
java·linux·运维·服务器·c语言·c++·学习
枫叶丹41 天前
【HarmonyOS 6.0】屏幕管理新特性:多屏坐标转换详解
开发语言·华为·harmonyos
提子拌饭1331 天前
开源鸿蒙跨平台Flutter开发:AR厨艺教学应用
android·flutter·华为·开源·ar·harmonyos·鸿蒙
海兰1 天前
【springboot】gradle快速镜像配置
spring boot·笔记·后端