Search code examples
androidbuttoncolorspressed

Android, change only clicked color of a button


I would like to change the default orange color that appears when someone press an Android button. I have done many searches but all I found was the use of selectors. I understand the principle, but I don't want to modify the grey aspect of the normal button (not pressed). But using selectors force to define all characteristics of all aspects (pressed or not).

I don't know how to obtain the default aspect of buttons in the light theme, so can anyone tell me where I can find the original parameters of the light theme or at least give me another means to simply change the color of the button when clicked?


Solution

  • You can copy the Android's selector into your project, the one that Android sets it by default to buttons, and modify only the state when the button is pressed by just changing one single drawable.

    You could find the file in \android-sdk\platforms\android-10\data\res\drawable\btn_default.xml