androidbuttonborderless

Make borderless image button small on Android


There is some closeable view in my app and it has a close button in header. I want make this button borderless and small.
The code:

<ImageButton
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    style="?android:attr/borderlessButtonStyle"
    android:layout_margin="0dp"
    android:padding="0dp"
    android:src="@android:drawable/ic_menu_close_clear_cancel"/>

In result the button is borderless but has much empty place around cross image (button is hitted on screenshot to make empty space visible)

How could I fix it?


Solution

  • You should use:

      android:background="?selectableItemBackgroundBorderless"