URL and Link repository

Tuesday, December 2, 2014

Custom Android Image Button with Animation

If using an image button with a custom background, then the usual touch animation is lost. In order to affect an animation upon touch or click, I created one custom_background.xml that references two backgrounds: a touched background and a default background.

Default background XML in drawable folder (rect_drawable.xml):

Touched background XML in drawable folder (rect_drawable2.xml):

This is the background referenced on each button (custom_back.xml):

The image button's XML would look like this:

No comments:

Post a Comment