How to have a transparent ImageButton: Android

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


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

    I believe the accepted answer should be: android:background="?attr/selectableItemBackground"

    This is the same as @lory105's answer but it uses the support library for maximum compatibility (the android: equivalent is only available for API >= 11)

    0 讨论(0)
  • 2020-11-27 09:20

    Setting the background to "@null" will make the button have no effect when clicked. This will be a better choice.

    style="?android:attr/borderlessButtonStyle"
    

    Later I found that using

    android:background="?android:attr/selectableItemBackground"
    

    is also a good solution. And you can inherit this attribute in your own style.

    0 讨论(0)
  • 2020-11-27 09:21

    Don't use null or transparent if you need a click animation. Better:

    //Rectangular click animation
    android:background="?attr/selectableItemBackground"
    
    //Rounded click animation
    android:background="?attr/selectableItemBackgroundBorderless"
    
    0 讨论(0)
  • 2020-11-27 09:21

    Use ImageView... it have transparent background by default...

    0 讨论(0)
  • 2020-11-27 09:21

    Set the background of the ImageButton as @null in XML

    <ImageButton android:id="@+id/previous"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:src="@drawable/media_skip_backward"
    android:background="@null"></ImageButton>
    
    0 讨论(0)
  • 2020-11-27 09:22

    It's android:background="@android:color/transparent"

    <ImageButton
        android:id="@+id/imageButton"
        android:src="@android:drawable/ic_menu_delete"
        android:background="@android:color/transparent"
    />
    
    0 讨论(0)
提交回复
热议问题