当前位置:网站首页>openharmony容器组件之GridContainer
openharmony容器组件之GridContainer
2022-08-09 13:12:00 【lplj717】
GridContainer:纵向排布栅格布局容器,仅在栅格布局场景中使用
GridContainer(options?: { columns?: number | ‘auto’, sizeType?: SizeType, gutter?: Length, margin?: Length})
columns:设置当前布局总列数。
sizeType:选用设备宽度类型(SizeType,默认Auto)
SizeType枚举类:
XS:最小宽度类型设备
SM:小宽度类型设备
MD:中等宽度类型设备
LG:大宽度类型设备
Auto:根据设备类型进行选择
gutter:栅格布局列间距
margin:栅格布局两侧间距
效果如图:
代码:
@Entry
@Component
struct GridContainerT {
@State sizeType: SizeType = SizeType.XS
build() {
Column({ space: 5 }) {
GridContainer({ columns: 7, sizeType: this.sizeType, gutter: 1 }) {
Row() {
Text('1')
.useSizeType({
xs: { span: 1, offset: 0 },
sm: { span: 3, offset: 0 },
md: { span: 5, offset: 0 },
lg: { span: 7, offset: 0 }
})
.height(50).backgroundColor(0x4682B4).textAlign(TextAlign.Center)
}
}.width('90%')
Text('Click Simulate to change the device width')
.fontSize(9)
.width('90%')
.fontColor(0xCCCCCC)
.textAlign(TextAlign.Center)
Row() {
Button('XS')
.onClick(() => {
this.sizeType = SizeType.XS
}).backgroundColor(0x317aff)
Button('SM')
.onClick(() => {
this.sizeType = SizeType.SM
}).backgroundColor(0x317aff)
Button('MD')
.onClick(() => {
this.sizeType = SizeType.MD
}).backgroundColor(0x317aff)
Button('LG')
.onClick(() => {
this.sizeType = SizeType.LG
}).backgroundColor(0x317aff)
}
}.width('100%').margin({ top: 5 })
}
}边栏推荐
猜你喜欢

Map mixed density function and quantile added line

GET POST PUT DELETE request in GIN

一篇ngork直接使用

FFmpeg multimedia file processing (the basic concept of ffmpeg processing stream data)

Oracle Recovery Tools修复空闲坏块

笔试题记录~~

搭建大型分布式服务(二)搭建会员服务

error Trailing spaces not allowed no-trailing-spaces 9:14 error Unexpected trailing comma

面试攻略系列(二)-- 秒杀系统

蓝桥历届真题-跑步锻炼
随机推荐
将 .json 格式 转换成 .xml格式
pytest 与 unittest 的区别
pytest 筛选用例
禁止输入(×),按键精灵小程序,快速上手
Unity3d_API_GPS_LocationService
目标检测基础
富媒体在客服IM消息通信中的秒发实践
JZ7 重建二叉树
JS本地存储 sessionStorage和localStorage
Professor Chen Qiang's "Machine Learning and R Application" course Chapter 16 Assignment
一篇ngork直接使用
NC15 求二叉树的层序遍历
行程和用户[阅读理解法]
NC96 判断一个链表是否为回文结构
NC192 二叉树的后序遍历
Q_06_05 文件结构
tianchi过往方法
RobotFramework 之 用户关键字
蓝桥历届真题-既约分数
利用信号灯和共享内存实现进程间同步通信