【鸿蒙学习笔记】属性学习迭代笔记

这里写目录标题

Text

cpp 复制代码
@Entry
@Component
struct PracExample {
  build() {
    Row() {
      Text('文本描述')
        .fontSize(40)// 字体大小
        .fontWeight(FontWeight.Bold)// 加粗
        .fontColor(Color.Blue)// 字体颜色
        .backgroundColor(Color.Red)// 背景颜色
        .width('50%')// 组件宽度
        .height("50")// 组件高度
        .size({ width: '80%', height: '70' })// 组件高宽  谁在下面以谁为主
        .borderRadius(20) // 四个角圆曲度
        .border({ width: 3, style: BorderStyle.Dashed })// 组件边框
        .margin(40)// 外边距
        .padding(15)// 内边距
        .textAlign(TextAlign.Center)// 字体居中
        .opacity(0.7) // 透明度
    }.backgroundColor(Color.Yellow)
  }
}

Image

cpp 复制代码
Image($r('app.media.zhibo'))
  .width(96)
  .height(96)
  .borderRadius(12)
  .objectFit(ImageFit.Fill) // 不明

Column

cpp 复制代码
@Entry
@Component
struct PracExample {
  build() {
    Column({ space: 10 }) {
      Text('文本描述').size({ width: '80%', height: '60' }).backgroundColor(Color.Red)
    }
    .width('100%')
    .height(150)
    .backgroundColor(Color.Pink)
    .border({ radius: { topLeft: 15, topRight: 15, } })
    .borderRadius(12)
    .margin(20)
    .padding(10)
    .alignItems(HorizontalAlign.Start) // 元素位置
    .justifyContent(FlexAlign.Center) // 主轴对齐方式
  }
}

Row

cpp 复制代码
Row() {

}
.alignItems(VerticalAlign.Center)
相关推荐
虾球xz1 小时前
游戏引擎学习第214天
学习·游戏引擎
LeonNo111 小时前
0411 | 软考高项笔记:项目立项
笔记
小矮强2 小时前
GNSS静态数据处理
经验分享·笔记
傻欣3 小时前
第八天 开始Unity Shader的学习之Blinn-Phong光照模型
学习·unity·游戏引擎
strongwyy6 小时前
9、nRF52xx蓝牙学习(pca10056.h学习)
单片机·嵌入式硬件·学习
每天题库6 小时前
2025 年江苏保安员职业资格考试经验分享
学习·安全·考试·题库·考证
Starry_hello world9 小时前
Linux 的准备工作
linux·笔记·有问必答
viperrrrrrrrrr711 小时前
大数据学习(105)-Hbase
大数据·学习·hbase
IT _oA11 小时前
Active Directory 域服务
运维·服务器·网络·windows·笔记
袖清暮雨12 小时前
Python刷题笔记
笔记·python·算法