Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove ImageButton's padding programmatically?

Tags:

android

widget

image = BitmapFactory.decodeResource(res, R.drawable.image);
button = new ImageButton(this);
button.setImageBitmap(image);

I want to remove padding between image and border of button. How can I do that?

like image 269
user1301568 Avatar asked Nov 17 '12 20:11

user1301568


1 Answers

You can use setPadding() to try to remove the space between the image and the border.

button.setPadding(0, 0, 0, 0);

Otherwise I suggest using a regular ImageView with an OnClickListener.

like image 179
Sam Avatar answered Oct 11 '22 21:10

Sam