How do I set a background image for an Android button but keep the gray button?

I need to set a background image for an android button (text button), but I want to keep the button grayed out. When I use setBackgroundResource () it has an image instead of a gray button. How can I hold down the gray button?

I tried using setCompoundDrawablesWithIntrinsicBounds, but the image only takes up part of the button even if I have no text.

Notes: I won't have text until I show the image, but the button must be a TextButton because sometimes there will be text without images, and images with text in others.

+2


a source to share


1 answer


To answer my own question, after a few hours of thinking, I realized that I can just create ImageButtons and TextButtons and set the visibility (8) of the buttons when I don't need them. Setting the visibility to 8 for the view makes it out of the layout and disappears altogether for now.



0


a source







All Articles