title: Android Clip image to bounds
body: <p>I have a custom <code>@drawable</code> as a background for a button. I have a bitmap and a shape on top of it. The problem is that the corners of the bitmap are not clipping to the shape, like illustrated bellow.</p>
  
  <p>My question is: Is there a way to clip the bitmaps to the bounds the shape? How?</p>
  
  <p><img src="https://i.stack.imgur.com/IOf0q.png" alt="enter image description here"></p>
  
  <p><strong>EDIT:</strong> Here is the XML:</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;shape&gt;
              &lt;solid
                  android:color="#8F8F8F" /&gt;
              &lt;stroke
                  android:width="1dp"
                  android:color="#8f8f8f" /&gt;
              &lt;corners
                  android:radius="8dp" /&gt;
              &lt;padding
                  android:left="10dp"
                  android:top="10dp"
                  android:right="10dp"
                  android:bottom="10dp" /&gt;
          &lt;/shape&gt;
      &lt;/item&gt;
      &lt;item&gt;
          &lt;layer-list&gt;
              &lt;item&gt;
                  &lt;!-- &lt;nine-patch android:src="@drawable/button"/&gt;--&gt;
                  &lt;bitmap android:src="@drawable/background_image" /&gt;
              &lt;/item&gt;
              &lt;item&gt;
                  &lt;shape&gt;
                      &lt;solid android:color="@android:color/transparent" /&gt;
                      &lt;stroke android:width="1dp" android:color="#8f8f8f" /&gt;
                      &lt;corners android:radius="12dp" /&gt;
                      &lt;padding android:bottom="10dp" android:left="10dp" android:right="10dp" android:top="10dp" /&gt;
                  &lt;/shape&gt;
              &lt;/item&gt;
          &lt;/layer-list&gt;
      &lt;/item&gt;
  &lt;/selector&gt;
  </code></pre>