Android: How to create a GridLayout [not GridView] programmatically?
Here is how You can create it programmatically:
GridLayout gridLayout = new GridLayout(getContext());// Add TitleGridLayout.Spec titleTxtSpecColumn = GridLayout.spec(2, GridLayout.BASELINE);GridLayout.Spec titleRowSpec = GridLayout.spec(0);TextView titleText = new TextView(getContext());titleText.setText("Title");gridLayout.addView(titleText, new GridLayout.LayoutParams(titleRowSpec , titleTxtSpecColumn));
For more details see ApiDemos examples.
You should try this :
gridLayout.setLayoutParams(prmsLinLyt);
and if you want to give values...
LinearLayout.LayoutParams prmsLinLyt = new LinearLayout.LayoutParams(90,100);where layout_width = 90and layout_height= 100