如何在代码中为图像按钮设置透明背景? [英] How to set transparent background for Image Button in code?
本文介绍了如何在代码中为图像按钮设置透明背景?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我可以使用 layout.xml
设置 ImageButton 背景透明:
I can set ImageButton background transparent in layout.xml
using:
android:background="@android:color/transparent"
如何使用 java 代码完成相同的事情?像 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);
这篇关于如何在代码中为图像按钮设置透明背景?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文