画像やテキストなどを含む ViewGroup (LinearLayout/RelativeLayout/etc など) を作成します。
この ViewGroup をクリック可能にします (たとえば、OnClicListener を割り当てることによって)。
この ViewGroup に 背景のドローアブルを割り当てます。
このバックグラウンド ドローアブルが状態リスト ドローアブルであることを確認してください:
https://developer.android.com/reference/android/graphics/drawable/StateListDrawable.html
http://developer.android.com/guide/topics/resources/ drawable-resource.html#StateList
適切なドローアブルをさまざまな状態に割り当てます (最も重要なのは state_pressed ですが、他の状態も処理したい場合があります)。
ユーザーがボタンを押すと、適切なドローアブルが表示され、ViewGroup がボタン (押すことができるもの) であるかのように表示されます。
押された状態の新しい画像を表示する OP の後に更新します。
StateListDrawable を持つ背景を使用して、画像/テキスト/などの上にあるビューを追加します。
<RelativeLayout >
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/somerealpngfile"
...
/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
...
/>
<View
android:id+"@+id/clickable_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/selectable_background"
android:clickable="true"
...
/>
</RelativeLayout>
res/drawable/selectable_background.xml
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true" android:drawable="@color/grid_state_pressed"/>
<item android:state_focused="true" android:drawable="@color/grid_state_focused"/>
<item android:drawable="@android:color/transparent"/>
</selector>
res/values/colors.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
...
<color name="grid_state_pressed">#BB7dbcd3</color>
<color name="grid_state_focused">#777dbcd3</color>
...
</resources>
ここで、色grid_state_pressed
と色grid_state_focused
は半透明です (つまり、アルファは 255 未満です)。
ユーザーが「ボタン」をクリックすると、View withR.id.clickable_view
は onClick を処理し、その背景色を変更して、画像とテキストを半透明の方法で透過させます。