Is it possible to make transparent just one instance of custom button?

38 views Asked by At

I have a custom button and its background is blue. I have used it in many activities but just in 1 place I want to make my button transparent without effecting other.

So how can I make transparent just one instance of custom button in my project?

2

There are 2 answers

0
Francesco Bocci On

You can add this in your XML: android:background="?android:attr/selectableItemBackground"

or this in your code: buttonVariable.setBackgroundColor(Color.TRANSPARENT);

0
Nagoor Bhasha On

You can declare variable in custom component. Initialize the variable only in the class you want to make the component as transparent. Override on draw method apply transparent bg to canvas.