title: customize toggle button on Android
body: <p>I customized the Toggle button by using a drawable defined by using a selector. I use this drawable as background for the Toggle button.</p>
  
  <pre><code>&lt;ToggleButton
      android:id="@+id/mailbox:toggle_button"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_gravity="bottom"
      android:layout_weight="1"
      android:background="@drawable/toggle_background"
      android:gravity="center_horizontal|center_vertical" /&gt;
  </code></pre>
  
  <p>The toggle_background is defined here:</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:drawable="@drawable/img1"
              android:state_checked="true" /&gt;
          &lt;item
              android:drawable="@drawable/img2"
              android:state_checked="false" /&gt;    
      &lt;/selector&gt;
  </code></pre>
  
  <p>The problem is that the image is always stretched. Is there a way to define an image for the two states that is not stretched? </p>
  
  <p>What I need is a background that will be stretched and in the center of the button an icon that must not be stretched.</p>
  
  <p>Is it possible?</p>