Removing EditText Background Color

I have editText and I want to set its background color as follows:

 RegistrationCountry.setBackgroundColor(Color.RED);

Now I need to remove this background color. Problem:

RegistrationCountry.setBackgroundColor(Color.TRANSPARENT);

I will lose the outline of the Edittext.

+4
source share
3 answers

you can use

RegistrationCountry.setBackgroundResource(android.R.drawable.editbox_background);

To set the background to a standard background image.

The problem arises when you call any of the methods setBackgroundX(), as this will replace the current background (that is, the "outline"), so when you call setBackgroundColor(Color.RED), you replace the outline with red, and then you replace red with transparency. What you need to do is replace the red color with the original background, as you can do with the line above.

+6
source

EditText, PorterDuff : http://developer.android.com/reference/android/graphics/PorterDuff.Mode.html.

:

RegistrationCountry.getBackground().setColorFilter(Color.RED, PorterDuff.Mode.SRC_IN);

:

RegistrationCountry.getBackground().clearColorFilter();
0

try setting the background:

RegistrationCountry.setBackgroundResource(0);

0
source

All Articles