GridLayout的几种常用设置
1个回答
展开全部
1.GridLayout设置:
GridLayout layout = new GridLayout();
// 设置容器的列数
layout.numColumns = 4;
// 设置容器上的组件是否等距分开
layout.makeColumnsEqualWidth = false;等价写法:GridLayout layout = new GridLayout(4, false);
2.GridData.grabExcessHorizontalSpace、GridData.grabExcessVerticalSpace
①GridData.grabExcessHorizontalSpace
GridData gridData = new GridData();
// 当容器大小变化时,组件所在列空间横向随容器的变化而变化
gridData.grabExcessHorizontalSpace = true;等价写法:GridData gridData = new GridData(GridData.GRAB_HORIZONTAL);
②GridData.grabExcessVerticalSpace
GridData gridData = new GridData();
// 当容器大小变化时,组件所在行空间纵向随容器的变化而变化
gridData.grabExcessVerticalSpace = true;等价写法:GridData gridData = new GridData(GridData.GRAB_VERTICAL);
3.GridData.FILL_HORIZONTAL、GridData.FILL_VERTICAL、GridData.FILL_BOTH
① GridData.FILL_HORIZONTAL:
GridData gridData = new GridData();
// 横向对齐方式
gridData.horizontalAlignment = GridData.FILL;
gridData.grabExcessHorizontalSpace = true;等价写法:GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
②GridData.FILL_VERTICAL
GridData gridData = new GridData();
// 纵向对齐方式
GridLayout layout = new GridLayout();
// 设置容器的列数
layout.numColumns = 4;
// 设置容器上的组件是否等距分开
layout.makeColumnsEqualWidth = false;等价写法:GridLayout layout = new GridLayout(4, false);
2.GridData.grabExcessHorizontalSpace、GridData.grabExcessVerticalSpace
①GridData.grabExcessHorizontalSpace
GridData gridData = new GridData();
// 当容器大小变化时,组件所在列空间横向随容器的变化而变化
gridData.grabExcessHorizontalSpace = true;等价写法:GridData gridData = new GridData(GridData.GRAB_HORIZONTAL);
②GridData.grabExcessVerticalSpace
GridData gridData = new GridData();
// 当容器大小变化时,组件所在行空间纵向随容器的变化而变化
gridData.grabExcessVerticalSpace = true;等价写法:GridData gridData = new GridData(GridData.GRAB_VERTICAL);
3.GridData.FILL_HORIZONTAL、GridData.FILL_VERTICAL、GridData.FILL_BOTH
① GridData.FILL_HORIZONTAL:
GridData gridData = new GridData();
// 横向对齐方式
gridData.horizontalAlignment = GridData.FILL;
gridData.grabExcessHorizontalSpace = true;等价写法:GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
②GridData.FILL_VERTICAL
GridData gridData = new GridData();
// 纵向对齐方式
微测检测5.10
2023-05-10 广告
2023-05-10 广告
您好!建议咨 深圳市微测检测有限公司,已建立起十余个专业实验室,企业通过微测检测就可以获得一站式的测试与认 证解决方案;(EMC、RF、MFi、BQB、QI、USB、安全、锂电池、快充、汽车电子EMC、汽车手机互 联、语音通话质量),认证遇...
点击进入详情页
本回答由微测检测5.10提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询