I am trying to make dynamic buttons of fixed dimensions. I am able to alter the height but unable to change the width. The width of the button seems to MATCH_PARENT (it takes up whole screen width. If there are two buttons, each button width is half screen width and when there is only one button, button width is screen width).
TableLayout table = (TableLayout)findViewById(r.id.table);
TableRow tableRow = new TableRow(this);
table.addView(tableRow);
Button button = new Button(this);
button.setLayoutParams(new TableRow.LayoutParams(30,30));
tableRow.addView(button);
Could anybody point out where I am going wrong.
Only This You have to do to change Button Dynamically
First I get Button
Then Button Click event I put This Code Only
And Works Fine. Try It. Will solve your Problem