I believe the best way to change android button color is using backgroundTint. It maintain animation and effect of button when clicked, while backgroundTint, while [background]https://developer.android.com/reference/android/view/View.html#attr_android:background override the entire drawable (loosing default animation/effects/state color).
Change background color programatically using AppCompat
support library (support up to API 4).
ViewCompat.setBackgroundTintList(button, ContextCompat.getColorStateList(this, android.R.color.white))
When you set the disable the button (button.isEnabled = false
), the color doesn't change to reflect the disabled state.
There are a few solutions available, but my favourite is View.setAlpha.
button.alpha = if (button.isEnabled) 1f else 0.5f