android imageview onClick animation

后端 未结 4 1727
生来不讨喜
生来不讨喜 2021-01-30 17:24

I guess this is kind of an odd question but I have tried setting onClicklistener on an ImageView and it has worked. But the problem is that the user cannot sense the click. I me

4条回答
  •  逝去的感伤
    2021-01-30 17:53

    You'll want to use a drawable that contains different images for the different states you want to support. Here's an example:

        
    
        
        
        
    
    

    Name this file img.xml or something and put it in your drawable directory, then set your ImageView's image to img.xml. @drawable/img_at_rest is the original image you're trying to use, while @drawable/img_pressed and @drawable/img_focused are the images to use for their respective states. You can also use solid colors instead of images if it's appropriate for your use case.

提交回复
热议问题