Removing the background color of an EditText

前端 未结 3 1801
一个人的身影
一个人的身影 2020-12-19 17:41

I have an editText and i want to set its background color to red like this:

 RegistrationCountry.setBackgroundColor(Color.RED);

Now i yould

3条回答
  •  感动是毒
    2020-12-19 18:11

    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.

提交回复
热议问题