In this simple tip, I’m going to show how to change android button on click or press color. If you want to change the click or press color of TextView or any android Layout you can do same way. Android Button onClick Event teaches you to handle button click and you can find different android button style at Android Button Examples.

Android Elevation Example
Relative Layout - Views Position in Android
Android Elevation Example

Define Color Value

To define color value, you have to create colors.xml file in your project values directory and add following.

Create a XML File in Drawable Directory

Create a button_background.xml file in your drawable folder and add button pressed/clicked, focused and default color. Final code of button_background.xml file looks like this.

Adding Buttons


Now, run your application and click any of two buttons. You will see different color at the time of click. In following screenshot, first button is at the time of button click/press and another is default.

Change Android Button on Click Color

Post a Comment

Powered by Blogger.