如何设置在code透明背景图像按钮? [英] How to set transparent background for Image Button in code?

查看:113
本文介绍了如何设置在code透明背景图像按钮?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以通过设置ImageButton的背景透明的 layout.xml

I can set ImageButton background transparent in layout.xml using:

android:background="@android:color/transparent"

我怎样才能用java code acomplish同样的事情? 像 ib.setBackgroundColor(???);

How I can acomplish same thing using java code? Something like ib.setBackgroundColor(???);

推荐答案

这是一个简单的只有你必须设置背景颜色为透明

This is the simple only you have to set background color as transparent

    ImageButton btn=(ImageButton)findViewById(R.id.ImageButton01);
    btn.setBackgroundColor(Color.TRANSPARENT);

这篇关于如何设置在code透明背景图像按钮?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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