views:

352

answers:

1

I need to set a background image for an android button (text button), but I want to keep the gray button. When i use the setBackgroundResource() it has the image in place of the gray button. How can I keep the gray button?

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

Notes: I will not have text while I display the image, but the button needs to be a TextButton because there will be text without images at times, and images with text at others.

A: 

Just to answer my own question, after hours of thinking, I realized I could just create ImageButtons and TextButtons, and set the visibility (setvisibility(8)) to the buttons when I do not need them. Setting the visibility to 8 for a view makes it be taken out of the layout, and completely disappear for the time being.

Jason Whiler