Removing The Background Color Of An Edittext
I have an editText and i want to set its background color to red like this: RegistrationCountry.setBackgroundColor(Color.RED); Now i yould like to remove this background color. T
Solution 1:
You can use
RegistrationCountry.setBackgroundResource(android.R.drawable.editbox_background);
To set the background to the standard background-image.
The problem arises when you call any of the setBackgroundX()
methods, as this will replace the current background (i.e. the 'outline'), so when you call setBackgroundColor(Color.RED)
you replace the outline with a red color, and then you replace the red with transparency. What you need to do is to replace the red with the original background, as can be done with the line above.
Solution 2:
If you just want to highlight the EditText
object, you can use PorterDuff instead: http://developer.android.com/reference/android/graphics/PorterDuff.Mode.html.
To set the color:
RegistrationCountry.getBackground().setColorFilter(Color.RED, PorterDuff.Mode.SRC_IN);
To remove the color:
RegistrationCountry.getBackground().clearColorFilter();
Solution 3:
try to set background by :
RegistrationCountry.setBackgroundResource(0);
Post a Comment for "Removing The Background Color Of An Edittext"