Is there a way to change the color of a disabled button in android through styles or some other form ?
I currently have the following,
drawable/button_de
UPDATE: For Android MaterialButton
For Android MaterialButton
there are two solutions, one for SDK >= v21 and another for SDK < v21.
Here I am also giving how to change the text color of the button depending whether it is enabled or disabled.
First create two color selector .xml
file in your color
folder. One for button color and another for button text color. For example button_state_colors.xml
for button color and button_text_state_colors.xml
for text color.
Here are those two color files:
button_state_colors.xml
:
button_text_state_colors.xml
:
Now for all versions of Android SDK you can change the color of button and it's text using style like:
in style.xml
:
in layout.xml
:
Only for SDK >= 21 you can direct change button color without using style
like: