I would like a Button background to remain a certain color after the button is clicked, and change colors again when some other button is pressed. I thought this was the \"
To change a Button's background color and make it persistent after being tapped you simply have to:
As an example in Kotlin and Material Buttons:
ColorStateSelector file (res/color/buttons_color_state.xml):
Layout XML:
Kotlin file:
val buttonOption = view?.findViewById(R.id.buttonOption)
// Implement any "if" checks or other control checks here if necessary
buttonOption.isSelected = true
// now the button is Green!
Best of lucks!