[英]How can I implement a java GUI that has multiple rows of buttons spaced equally apart from one another
[英]How can I stick buttons to one another in TableLayout?
1)如何使所有按鈕彼此粘在一起,以使任意兩個按鈕之間沒有空間? 2)如何使炸彈的圖片在按鈕內作為背景(我做錯了)這是一些添加圖像的代碼:
clickedButton.setPadding(0,0,0,0);
int newWidth = clickedButton.getWidth();
int newHeight = clickedButton.getHeight();
Bitmap originalBitmap = BitmapFactory.decodeResource(getResources(), R.drawable.b64);
Bitmap scaledBitmap = Bitmap.createScaledBitmap(originalBitmap, newWidth, newHeight, true);
Resources resource = getResources();
clickedButton.setBackground(new BitmapDrawable(resource, scaledBitmap));
非常感謝你!
為了使它們粘在一起,我將嘗試刪除所有可能的邊距,因為您已經嘗試過填充。 如果它不起作用,我將嘗試使用一些負值來實現我想要的功能。
至於按鈕中的圖像,我認為您可以使用ImageButton
代替按鈕。 單擊后,它會更改背景圖像(或不,我不理解您的游戲[?])。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.