How to set transparent background for Image Button in code?

前端 未结 7 557
醉话见心
醉话见心 2020-12-25 09:03

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

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

How I can

7条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-25 09:46

    Try like this

    ImageButton imagetrans=(ImageButton)findViewById(R.id.ImagevieID);
    
    imagetrans.setBackgroundColor(Color.TRANSPARENT);
    

    OR

    include this in your .xml file in res/layout

    android:background="@android:color/transparent 
    

提交回复
热议问题