如何设置在code透明背景图像按钮?如何设置、按钮、图像、透明

2023-09-06 01:28:59 作者:明月本无心

我可以通过设置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);