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();
// 纵向对齐方式
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询