当前位置: 首页 > news >正文

【鸿蒙学习笔记】尺寸设置・layoutWeight・对子组件进行重新布局

官方文档:尺寸设置

目录标题

  • layoutWeight:对子组件进行重新布局

layoutWeight:对子组件进行重新布局

设置了layoutWeight属性的子元素与兄弟元素占主轴尺寸按照权重进行分配,忽略元素本身尺寸设置。

// 引入包名
import { http } from '@kit.NetworkKit';
import { BusinessError } from '@kit.BasicServicesKit';@Entry
@Component
struct PracExample {build() {Column() {Row() {Text('1/3').backgroundColor(Color.Pink).textAlign(TextAlign.Center).size({ width: '30%', height: 110 })Text('2/3').backgroundColor(Color.Green).textAlign(TextAlign.Center).size({ width: '30%', height: 110 })Text('no').backgroundColor(Color.Yellow).textAlign(TextAlign.Center).size({ width: '10%', height: 110 })}.backgroundColor(Color.Gray).size({ width: '100%', height: 140 })Divider().height(10)Row() {// 权重1,占主轴剩余空间1/3Text('1/3').backgroundColor(Color.Pink).textAlign(TextAlign.Center).size({ width: '30%', height: 110 }).layoutWeight(1)// 权重2,占主轴剩余空间2/3Text('2/3').backgroundColor(Color.Green).textAlign(TextAlign.Center).size({ width: '30%', height: 110 }).layoutWeight(2)// 未设置,组件按照自身尺寸渲染Text('no').backgroundColor(Color.Yellow).textAlign(TextAlign.Center).size({ width: '10%', height: 110 })}.backgroundColor(Color.Black).size({ width: '100%', height: 140 })}}
}

在这里插入图片描述

http://www.lryc.cn/news/398994.html

相关文章:

  • vue实现表单输入框数字类型校验功能
  • JS登录页源码 —— 可一键复制抱走
  • Kithara与OpenCV (一)
  • 什么是软件定义安全SDSec
  • 【C语言】C语言可以做什么?
  • WordPress 主题技巧:给文章页增加“谁来过”模块。
  • 【vue组件库搭建07】Vitest单元测试
  • JSONObject和Map<String, Object>的转换
  • C# 建造者模式(Builder Pattern)
  • 初阶数据结构速成
  • nx上darknet的使用-目标检测-在python中的使用
  • Python高级(四)_内存管理
  • 关键路径-matlab
  • JavaDS —— 单链表 与 LinkedList
  • LangChain —— Message —— how to filter messages
  • conda install问题记录
  • 【python】IPython的使用技巧
  • 常用知识点问答
  • paddlenlp cpu windows 下测试gpt
  • uboot的功能
  • java导出word实现
  • Flink 提交作业的方式
  • JVM系列 | 垃圾收集算法
  • 深入理解Spring Boot中的事件驱动架构
  • Moldflow安装包下载:附网盘地址+详细教程步骤
  • 2024辽宁省数学建模B题【钢铁产品质量优化】思路详解
  • C++基础入门(上)
  • 基于深度学习的情感分析
  • mybatis 延迟加载
  • 使用QT5.14.2开发族谱管理软件过程记录