2013-04-13 34 views
2

刪除這些空格這裏是我的方法,而且這種方法的輸出是http://l1304.hizliresim.com/18/f/m1r29.jpg我如何能在Android的

我不希望這些按鈕之間的任何空間。我怎樣才能做到這一點?

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


    } 
+0

[看這個](http://stackoverflow.com/questions/14105631/removing-image-button-padding-android/14105941#14105941) – Ahmad

回答

0

查看類似問題的解答herehere

基本上,您可以創建自己的9patch圖像,或者只是將layout_marginLeft和layout_marginRight更改爲負值。

如果您決定設置邊距,則不會希望以像素爲單位進行設置。要將邊距設置爲dp而不是像素,可以使用this answer中的公式。

+0

我解決了我使用ImageButtons的問題,謝謝。 – Burak