title: Android ImageButton background color
body: <p>I have an ImageButton with a background image that has some transparency. By default, the button gets a grey background where the transparency pixels are - due to the Holo.Light theme. I tried setting the background color of the button to transparent via the <code>setBackgroundColor(Color.TRANSPARENT)</code> method. That works just fine and does what I need except now my button no longer has the light blue color when focused/pressed and looks rather flat (no borders around it, so it looks like an image).</p>
  
  <p>I googled and saw that you can assign selectors as explained <a href="http://www.mkyong.com/android/android-imagebutton-selector-example/" rel="noreferrer">here</a> but that would mean that I have to specify an image per button state and I don't want to do that. I want to inherit the focuses/pressed colors from the theme but overwrite the normal button background (when not pressed/focused) to transparent instead of grey. How can I achieve that?? Please provide a working example as I have tried many different combinations with no success.</p>
  
  <p><strong>Edit</strong>
  Thank you all for helping. I figured out how to make this work without having to recreate the same image with the focused and pressed states for each button!</p>
  
  <p>Here is my solution:</p>
  
  <p>My button is defined as:</p>
  
  <pre><code>&lt;ImageButton
              android:id="@+id/ImageButton05"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_gravity="center"
              android:background="@drawable/button" /&gt;
  </code></pre>
  
  <p>And my background XML file (titled button.xml) is defined as follows:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;selector xmlns:android="http://schemas.android.com/apk/res/android"&gt;
  
      &lt;item android:state_pressed="true"&gt;
          &lt;layer-list&gt;
              &lt;item android:drawable="@drawable/btn_default_pressed_holo_light"&gt;&lt;/item&gt;
              &lt;item android:drawable="@drawable/network_wifi"&gt;&lt;/item&gt;
          &lt;/layer-list&gt;
      &lt;/item&gt;
      &lt;item android:state_focused="true"&gt;
          &lt;layer-list&gt;
              &lt;item android:drawable="@drawable/btn_default_focused_holo_light"&gt;&lt;/item&gt;
              &lt;item android:drawable="@drawable/network_wifi"&gt;&lt;/item&gt;
          &lt;/layer-list&gt;
      &lt;/item&gt;
      &lt;item android:state_hovered="true"&gt;
          &lt;layer-list&gt;
              &lt;item android:drawable="@drawable/btn_default_focused_holo_light"&gt;&lt;/item&gt;
              &lt;item android:drawable="@drawable/network_wifi"&gt;&lt;/item&gt;
          &lt;/layer-list&gt;
      &lt;/item&gt;
      &lt;item&gt;
          &lt;layer-list&gt;
              &lt;item android:drawable="@drawable/btn_default_normal_holo_light"&gt;&lt;/item&gt;
              &lt;item android:drawable="@drawable/network_wifi"&gt;&lt;/item&gt;
          &lt;/layer-list&gt;
      &lt;/item&gt;
  &lt;/selector&gt;
  </code></pre>