How to have a transparent ImageButton: Android

后端 未结 19 1820
庸人自扰
庸人自扰 2020-11-27 08:56


        
相关标签:
19条回答
  • 2020-11-27 09:38

    DON'T USE A TRANSAPENT OR NULL LAYOUT because then the button (or the generic view) will no more highlight at click!!!

    I had the same problem and finally I found the correct attribute from Android API to solve the problem. It can apply to any view.

    Use this in the button specifications:

    android:background="?android:selectableItemBackground"
    
    0 讨论(0)
  • 2020-11-27 09:40

    You can also use a transparent color:

    android:background="@android:color/transparent"
    
    0 讨论(0)
  • 2020-11-27 09:41

    Use "@null" . It worked for me.

    <ImageButton
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:srcCompat="@drawable/bkash"
        android:id="@+id/bid1"
        android:layout_alignParentTop="true"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true"
        android:background="@null" />
    
    0 讨论(0)
  • 2020-11-27 09:43

    Try using null for the background ...

    android:background="@null"
    
    0 讨论(0)
  • 2020-11-27 09:43

    in run time, you can use following code

    btn.setBackgroundDrawable(null);
    
    0 讨论(0)
  • 2020-11-27 09:44

    This is programatically set background color as transparent

     ImageButton btn=(ImageButton)findViewById(R.id.ImageButton01);
     btn.setBackgroundColor(Color.TRANSPARENT);
    
    0 讨论(0)
提交回复
热议问题