Android – Button with background changed on click

This is how to make a button with background changed on press without drawables

One could think the behaviour in the bellow screen-shot is easy to accomplish but the truth is that it’s not. I’ve seen many questions and complicated solutions presented on stackoverflow with selectors and buttons and even people saying that it’s not possible to be done at all. Well, actually with regular buttons it is indeed difficult, but that’s why ImageButtons exist, so you may use this easier solution.

Button not pressed, than pressed

Use an ImageButton with background targeting a selector of two colors and the icon which doesn’t change as src image. The same way you could set a text.


The selector looks like this:

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="" >
    <item android:state_pressed="false">
            <solid android:color="#552277AA" />
	<item >
            <solid android:color="#ff2277AA" />

Related Posts

Leave a reply