phicdy devlog

Androidアプリ開発やその他技術系の記事をたまに書きます

AndroidとかiOSとかモバイル多め。その他技術的なことも書いていきます。

【Android】画像が押されたときの背景を簡単につける

ImageButtonを使えば簡単にできたので自分用にメモ。

<ImageButton
  android:id="@+id/ib_button"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:src="@drawable/your_imgae"
  android:background="?android:selectableItemBackground"
  android:contentDescription="@string/your_image_desc" />

参考

stackoverflow.com

stackoverflow.com