I have one little problem…Here is my code..Is there a way to “distribute weights evenly” for those buttons what I made.. I tried to button[i].setWidth().. but when I turn around my phone it looks ugly.. so Is there away to distribute buttons width auto?
ViewGroup row1 = (ViewGroup)findViewById(R.id.TableRow02);
ViewGroup row2 = (ViewGroup)findViewById(R.id.TableRow04);
ViewGroup row3 = (ViewGroup)findViewById(R.id.TableRow06);
ViewGroup row4 = (ViewGroup)findViewById(R.id.TableRow08);
ViewGroup row5 = (ViewGroup)findViewById(R.id.TableRow10);
Button button[] = new Button[36];
for(int i=1;i<36;i++)
{
button[i] = new Button(this);
if(i==32||i==33||i==34||i==35){button[i].setVisibility(-1);}
button[i].setText("700€");
button[i].setTextSize(10);
button[i].setWidth(20);
// Insert buttons in rows
if(i<8){row1.addView(button[i]);}
else if(i<15){row2.addView(button[i]);}
else if(i<22){row3.addView(button[i]);}
else if(i<29){row4.addView(button[i]);}
else if(i<36){row5.addView(button[i]);}
}
Tactically, put the buttons in a
LinearLayoutand setandroid:layout_weight="1"for each of them.Strategically, design a decent UI, one that does not involve a row of 36 buttons.