如何以编程方式删除 ImageButton 的填充? [英] How to remove ImageButton's padding programmatically?

查看:27
本文介绍了如何以编程方式删除 ImageButton 的填充?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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?

推荐答案

您可以使用 setPadding() 尝试去除图像和边框之间的空间.

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

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

否则我建议使用带有 OnClickListener 的常规 ImageView.

Otherwise I suggest using a regular ImageView with an OnClickListener.

这篇关于如何以编程方式删除 ImageButton 的填充?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆