How to set transparent background for Image Button in code?

前端 未结 7 591
醉话见心
醉话见心 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 10:07

    If you want to use android R class

    textView.setBackgroundColor(ContextCompat.getColor(getActivity(), android.R.color.transparent));
    

    and don't forget to add support library to Gradle file

    compile 'com.android.support:support-v4:23.3.0'
    

提交回复
热议问题