Apply Material Design Touch Ripple to ImageButton? Apply Material Design Touch Ripple to ImageButton? xml xml

Apply Material Design Touch Ripple to ImageButton?


For even better result:

<ImageButton    android:layout_width="wrap_content"    android:layout_height="wrap_content"    android:src="@android:drawable/ic_button"    android:background="?attr/selectableItemBackgroundBorderless"/>


You can just add a background to your ImageButton like this :

<ImageButton    android:layout_width="wrap_content"    android:layout_height="wrap_content"    android:src="@android:drawable/btn_dialog"    android:background="?android:attr/selectableItemBackground" />


If you already have a background and don't want to change it, use foreground;

<ImageButton    android:layout_width="60dp"    android:layout_height="match_parent"    android:background="@drawable/preview_in_4k_background"    android:src="@drawable/ic_full_screen_24px"    android:layout_marginLeft="5dp"    android:foreground="?attr/selectableItemBackgroundBorderless"    android:layout_column="2"/>