Why is a standard ImageButton too small in Android?

90 Views Asked by At

For most of the UI of an app, I want it as conventional as possible. An ImageButton is devised by following the official recommendation

<ImageButton
    android:id="@+id/imageButtonCloseAd"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="right"
    android:onClick="onClick"
    android:contentDescription="@string/close"
    android:src="@drawable/baseline_cancel_24" />

The icon baseline_cancel_24 is created by using all default settings of the vector assets: enter image description here

Android Studio gives the error "This item's height is 32dp. Consider making the height of this touch target 48dp or larger. " for the button though the app can be built with this error: enter image description here

Could anyone shed some light on this and offer the conventional way to make an ImageButton comply with the guideline?

In case you wonder and for your convenience, here is the official sample code for ImageButton:

  <ImageButton
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:contentDescription="A tiny Android icon"
      android:src="@drawable/baseline_android_24"
      app:tint="#ff0000" />
0

There are 0 best solutions below