1) How can I make all buttons stick to one another so that there is no space between any 2 buttons? 2) How can I make the picture of the bomb be inside the button as backround(I have it done wrongly) Here is some code how I added image:
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));
Thank you very much!
To make them stick together I would try removing any possible margins, since you already tried padding. If it doesn't work I would try to work some negative values that might do what I wanted.
As for the images in the buttons, I think you could use ImageButton
instead of button. Once it is clicked, it changes the background image (or not, I don't understand your game[?]).
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.