如何在Android中删除这些空格

时间:2013-04-13 19:22:28

标签: java android button space

这是我的方法,此方法的输出为http://l1304.hizliresim.com/18/f/m1r29.jpg

我不希望这些按钮之间有任何空格。我怎么能这样做?

public void butonOlustur(){
     TableRow layout1 = (TableRow) findViewById(R.id.tableRow1);
     TableRow layout2 = (TableRow) findViewById(R.id.tableRow2);
     TableRow layout3 = (TableRow) findViewById(R.id.tableRow3);
     TableRow layout4 = (TableRow) findViewById(R.id.tableRow4);
     TableRow layout5 = (TableRow) findViewById(R.id.tableRow5);
     TableRow[] layouts = new TableRow[6];
     layouts[0]=layout1;
     layouts[1]=layout2;
     layouts[2]=layout3;
     layouts[3]=layout4;
     layouts[4]=layout5;
     Button[][] myButton = new Button[4][25];
     for(int j = 0; j <myButton.length; j++){
     for(int i =0 ; i <25; i++){

         Button temp = new Button(this);
         myButton[j][i] = temp;
         layouts[j].addView(myButton[j][i], 15, 15);


     }
     layouts[j] = layouts[j+1];
     }


    }

1 个答案:

答案 0 :(得分:0)

查看回答herehere的类似问题。

基本上,您可以创建自己的9patch图像,或者只是将layout_marginLeft和layout_marginRight更改为负值。

如果您决定设置边距,则不需要以像素为单位进行设置。要将边距设置为dp而不是像素,可以使用this answer中的公式。

相关问题