Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove the background of a (regular) view (Android)

I have the following code:

View view = new View(this);  
view.setBackgroundDrawable(...);  
...  

And here I want to remove that background.
Just turn it back as it was before.

I tried these and failed:

view.setBackgroundDrawable(null);  
view.setBackgroundColor(0xFF000000);  
view.setBackgroundColor(0x00000000);  

Any more ideas?

like image 948
Tal A. Avatar asked May 01 '11 20:05

Tal A.


1 Answers

view.setBackgroundDrawable(null); should work.

You may try one of these:

v.setBackgroundColor(Color.WHITE);
//or
v.setBackgroundColor(Color.parseColor("#ff0000")); //whatever color

Make sure the view you're applying the background to is the correct instance.

like image 85
tacone Avatar answered Nov 11 '22 19:11

tacone