I have the following code for a button in the layout file for my application
A button has a set of states that can be configured like this:
You can create this as a file in your res/drawables folder and then use it in your button as the background. Supose that you called that file "my_button.xml" you can then use it like this:
Or like this:
my_button.setBackgroundDrawable(getResources().getDrawable(R.drawable.my_button));
Your color can be defined in the colors.xml in the res/values folder. If you don't have this file you can create it (android will recognize it). This is a good practise, but you can also replace your_color by #DC143C in the code above.
#DC143C
Note that this color is already set for crimson.
You can also add an image for the background, replacing the "@color/your_color" by "@drawable/your_image".
For more information you can follow this link in stackoverflow.