I\'m new to android programming. How do I change the color of a button?
Through Programming:
btn.setBackgroundColor(getResources().getColor(R.color.colorOffWhite));
and your colors.xml must contain...
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorOffWhite">#80ffffff</color>
</resources>
If you are trying to set the background as some other resource file in your drawable folder, say, a custom-button.xml, then try this:
button_name.setBackgroundResource(R.drawable.custom_button_file_name);
eg. Say, you have a custom-button.xml file. Then,
button_name.setBackgroundResource(R.drawable.custom_button);
Will set the button background as the custom-button.xml file.