1 Star 0 Fork 1

程序员四海 / LearnHos

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
Equalization.ets 1.38 KB
一键复制 编辑 原始数据 按行查看 历史
程序员四海 提交于 2022-12-18 15:13 . 自适应布局-均分能力
@Entry
@Component
struct Equalization {
//自适应布局-均分能力
build() {
Column() {
//示例:当设备的宽度增加或减少时,子组件的宽度不变,增加或减少的区域全部均匀分配给空白区域
//实现方案1:容器Flex + 参数justifyContent
Flex({ justifyContent: FlexAlign.SpaceEvenly }) {
Text('T1')
.backgroundColor(Color.Red)
.fontSize(88)
Text('T2')
.backgroundColor(Color.Pink)
.fontSize(88)
Text('T3')
.backgroundColor(Color.Gray)
.fontSize(88)
}
//实现方案2:容器Row + 属性justifyContent
Row() {
Text('T1')
.backgroundColor(Color.Red)
.fontSize(88)
Text('T2')
.backgroundColor(Color.Pink)
.fontSize(88)
Text('T3')
.backgroundColor(Color.Gray)
.fontSize(88)
}
.width('100%')
.justifyContent(FlexAlign.SpaceEvenly)
//实现方案3:容器Row + 组件Blank
Row() {
Blank()
Text('T1')
.backgroundColor(Color.Red)
.fontSize(88)
Blank()
Text('T2')
.backgroundColor(Color.Pink)
.fontSize(88)
Blank()
Text('T3')
.backgroundColor(Color.Gray)
.fontSize(88)
Blank()
}
.width('100%')
}
}
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
TypeScript
1
https://gitee.com/csh1998/LearnHos.git
git@gitee.com:csh1998/LearnHos.git
csh1998
LearnHos
LearnHos
master

搜索帮助