This GridLayout is going in my app that has a lot of levels. Each level has a different number of rows and columns. I assume that this GridLayout would be my best bet to use to satisfy my needs. Also, all need to be done at runtime prorammatically.
I am having trouble understanding how to use GridLayout.spec()
. I am trying to follow this excellent example but just cannot grasp it fully. Let's say, for example, I want a GridLayout with 3 columns and 4 rows.
GridLayout.LayoutParms params1 = new GridLayout.Layout(rowSpec, columnSpec); //what's parameters?
gameplayGridLayout.setColumnCount(3);
gameplayGridLayout.setRowCount(4);
puzzle.addView(gameplayGridLayout, params1);
In my linked example above, he used code like below to set the "specs"
.
Spec row1 = GridLayout.spec(0, 2);
Spec row2 = GridLayout.spec(2);
Spec row3 = GridLayout.spec(3);
Spec row4 = GridLayout.spec(4, 2);
Spec col0 = GridLayout.spec(0);
Spec col1 = GridLayout.spec(1);
Spec colspan2 = GridLayout.spec(0, 2);
I don't understand the parameters of those variables either. I've tried reading the documentation but it didn't give me any clarity. Can someone help me with my example code of the 3x4 GridLayout which also helps explain what the Spec
s are?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…