简体   繁体   English

如何在Android中删除这些空格

[英]How can i delete these spaces in Android

Here is my method, and this method's output is http://l1304.hizliresim.com/18/f/m1r29.jpg 这是我的方法,该方法的输出为http://l1304.hizliresim.com/18/f/m1r29.jpg

I don't want any spaces between these buttons. 我不希望这些按钮之间有任何空格。 How can i do this? 我怎样才能做到这一点?

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];
     }


    }

See similar questions answered here or here . 看到这里这里回答的类似问题。

Basically, you can create your own 9patch image, or just change the layout_marginLeft and layout_marginRight to negative values. 基本上,您可以创建自己的9patch图像,也可以只将layout_marginLeft和layout_marginRight更改为负值。

If you decide to set the margins, you won't want to set it in pixels. 如果决定设置边距,则不需要以像素为单位进行设置。 To set the margins to dp rather than pixels, you can use the formula found in this answer . 要将边距设置为dp而不是像素,可以使用此答案中的公式。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM