我想以编程方式在GridLayout上应用colspan和rowspan。我搜索了很多相同的东西。我有些疑惑:
答案 0 :(得分:2)
如果你有高度和宽度,只想以编程方式创建GridLayout params,请使用:
GridLayout.LayoutParams param =new GridLayout.LayoutParams();
param.height = LayoutParams.WRAP_CONTENT;
param.width = LayoutParams.WRAP_CONTENT;
layoutParams.rowSpec = GridLayout.spec(GridLayout.UNDEFINED, item.getRowSpan());
layoutParams.columnSpec = GridLayout.spec(GridLayout.UNDEFINED, item.getColumnSpan());
gridlayout.setLayoutParams(param);