If you want to do this programmatically then you just have to do: button. setBackgroundResource(R. drawable.
Try this
RelativeLayout relative = (RelativeLayout) findViewById(R.id.widget29);
relative.setBackgroundResource(0);
Check the setBackground functions in the RelativeLayout documentation
setBackgroundResource(0)
is the best option. From the documentation:
Set the background to a given resource. The resource should refer to a Drawable object or 0 to remove the background.
It works everywhere, because it's since API 1.
setBackground
was added much later, in API 16, so it will not work if your minSdkVersion
is lower than 16.
This helped me remove background color, hope it helps someone.
setBackgroundColor(Color.TRANSPARENT)
Try this code:
imgView.setImageResource(android.R.color.transparent);
also this one works:
imgView.setImageResource(0);
but be careful this one doesn't work:
imgView.setImageResource(null);
I try this code in android 4+:
view.setBackgroundDrawable(0);
Best performance on this method :
imageview.setBackgroundResource(R.drawable.location_light_green);
Use this.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With