GridLayout gridLayout = new GridLayout(this);
gridLayout.setColumnCount(5);
gridLayout.setRowCount(2);
rootView.addView(gridLayout);
GridLayout.LayoutParams gridParams = new GridLayout.LayoutParams(GridLayout.spec(0,1),
GridLayout.spec(0,2));
Button button = new Button(this);
button.setText(" button 1");
button.setWidth(400);
button.setHeight(200);
gridLayout.addView(button, gridParams);
gridParams = new GridLayout.LayoutParams(GridLayout.spec(1),
GridLayout.spec(0,1));
Button button1 = new Button(this);
button1.setText(" button 2");
button1.setWidth(200);
button1.setHeight(200);
gridLayout.addView(button1, gridParams);
gridParams = new GridLayout.LayoutParams(GridLayout.spec(1),
GridLayout.spec(1,2));
Button button2 = new Button(this);
button2.setText(" button 3");
button2.setWidth(400);
button2.setHeight(200);
gridLayout.addView(button2, gridParams);
gridParams = new GridLayout.LayoutParams(GridLayout.spec(0,1),
GridLayout.spec(2,2));
Button button3 = new Button(this);
button3.setText(" button 4");
button3.setWidth(400);
button3.setHeight(200);
gridLayout.addView(button3, gridParams);
gridParams = new GridLayout.LayoutParams(GridLayout.spec(0,2),
GridLayout.spec(4,1));
Button button5 = new Button(this);
button5.setText(" button 5");
button5.setWidth(200);
button5.setHeight(400);
gridLayout.addView(button5, gridParams);