I have plenty of buttons that when pressed, should change the background color and when released, should revert to the original color (transparent).
The goal is to do this by creating as few files as possible and avoiding the need of manual handling of touch events.
Simply using a StateListDrawable
is not a nice way, because it replaces the image with another one, instead of just adding a background to the image. In such a case there should be two images per button: one for up and one for down state of the button. Currently I have only for the up state, and want to remain like that.
Another way would be to use a Layer list
, and then again for each button there should be a separate xml for the down state, that will combine the background color and the 'foreground' image.
Is there another way, some generic approach, that I am missing?