删除一个EditText的背景颜色 [英] Removing the background color of an EditText

查看:151
本文介绍了删除一个EditText的背景颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个EditText,我想设置它的背景色为红色是这样的:

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

 RegistrationCountry.setBackgroundColor(Color.RED);

现在我yould要删除这个背景色。 使用问题:

Now i yould like to remove this background color. The problem using:

RegistrationCountry.setBackgroundColor(Color.TRANSPARENT);

时,我就失去了EDITTEXT轮廓。

Is that i will lose the Edittext outline.

推荐答案

您可以使用

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

要设置背景为标准的背景图像。

To set the background to the standard background-image.

当你调用任何的 setBackgroundX()方法,因为这会的替换的当前背景(问题出现,即纲要 ),所以当你调用 setBackgroundColor(Color.RED)你用红色代替轮廓,然后用透明替换红色。你需要做的是与原来的背景取代红色,这可与上面的线来完成。

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.

这篇关于删除一个EditText的背景颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆