Touch feedback on pictures in Android xml

903 Views Asked by At

Anyone know a way to get ImageView (images/pictures) to have touch feedback overlay with Xml.

I have tried to do it by creating a drawable background but no luck making work. I've tried it like button feedback but that is unsuccessful for me. I know it is possible.

Thanks

1

There are 1 best solutions below

0
On

Why not use an ImageButton?

You can use a selector like so to have the background change on press

  <?xml version="1.0" encoding="utf-8"?>
  <selector xmlns:android="http://schemas.android.com/apk/res/android">
      <item android:state_pressed="true"
       android:drawable="@drawable/button_pressed" /> <!-- pressed -->
      <item android:drawable="@drawable/button_normal" /> <!-- default -->
  </selector>