The equivalent of layout_column
and layout_row
, as with all layout_...
parameters, is to be found as a parameter of a subclass of LayoutParams
.
In this case it's GridLayout.LayoutParams
, and we use it like this (for a 2x2 grid with a subview in the final row and column, centred within the cell):
gridLayout.setColumnCount(2);
gridLayout.setRowCount(2);
gridLayout.addView(subview, new GridLayout.LayoutParams(
GridLayout.spec(1, GridLayout.CENTER),
GridLayout.spec(1, GridLayout.CENTER)));
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…