How to set background image for 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 gray button. When i use the setBackgroundResource() it has the image in place of the gray bu开发者_开发知识库tton. 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.
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.
精彩评论