Check Mobile App
Read now
Start a Project

Changing the color of a button when it is not enabled


UI part of every application is the key for user engagement, this fact is known by all.
Building a better UI in android is making better and interactive views (xmls).

While working i just wanted to change the color of a button when the button is diabled from default color to some color of my choice (like just change the alpha value or some light toned similar color, so that the user understands that the button is disabled).

Lets have a look at how to implement the same :

  1.  Create a new drawable file with selector as the parent tag
  2. Apply this drawable file on your button’s background

CODE : my_button_background_selector

Now you have to add only one line to your button in your xml file.

And it is done.

You can also replace the color with your custom drawable file.

Keep coding , keep sharing 🙂


. . .

Leave a Comment

Your email address will not be published. Required fields are marked*


  • Shashankesh Upadhyay
    thank you man. but in activity.xml file of button declaration you should edit some correction in line 5; android:background=”@drawable/my_button_background_selector”
  • Marco
    worked for me… thanks!
  • css.php

    When I think in getting solutions for my Ecommerce Platform, I think of Webkul. They have been such a blessing in our business. We have spent thousands of dollars in support and modules from them. We love their support team. They work very closely with us, and they always go the extra mile when we need help.

    Michael Urresta

    Michael Urresta

    Talk to Sales


    Live Chat
    Start a Project

      Message Sent!

      If you have more details or questions, you can reply to the received confirmation email.

      Back to Home