How to reset a button's background color to default?

use:

btn.setBackgroundResource(android.R.drawable.btn_default);

If the background color was set using

btn.getBackground().setColorFilter(Color.RED, PorterDuff.Mode.MULTIPLY);

it can be reset using:

btn.getBackground().clearColorFilter();

In contrast to button.setBackgroundColor() setting the color this way preserves the button's shape.


Nobody mentioned TRANSPARENT use it like this

findViewById(R.id.button_id).setBackgroundColor(Color.TRANSPARENT);

Thank me later

Tags:

Android