title: Preventing shapes scaling in a LayeredList without using Bitmap
body: <p>Trying to use LayerDrawable (defined in XML as layer-list) to layer several shape drawables onto one another; to be used as a background for a layout.</p>
  
  <p>The Android guide (<a href="http://developer.android.com/guide/topics/resources/drawable-resource.html#LayerList" rel="nofollow noreferrer">for LayerList</a>) says:</p>
  
  <blockquote>
    <p>All drawable items are scaled to fit the size of the containing View,
    by default. Thus, placing your images in a layer list at different
    positions might increase the size of the View and some images scale as
    appropriate. To avoid scaling items in the list, use a <code>&lt;bitmap&gt;</code>
    element inside the <code>&lt;item&gt;</code> element to specify the drawable and define
    the gravity to something that does not scale, such as "center".</p>
  </blockquote>
  
  <p>I don't want my shapes to scale, but I'm unsure how to wrap them in <code>bitmap</code> tags correctly: it produces an error if I do it as follows:</p>
  
  <pre><code>&lt;layer-list xmlns:android="http://schemas.android.com/apk/res/android"&gt;
      &lt;item&gt;
          &lt;bitmap
              android:src="@drawable/layer_one"
              android:gravity="center" /&gt;
      &lt;/item&gt;
      &lt;item&gt;
          &lt;bitmap
              android:src="@drawable/layer_two"
              android:gravity="center" /&gt;
      &lt;/item&gt;
      &lt;item&gt;
          &lt;bitmap
              android:src="@drawable/layer_three"
              android:gravity="center" /&gt;
      &lt;/item&gt;
      &lt;item&gt;
          &lt;bitmap
              android:src="@drawable/layer_four"
              android:gravity="center" /&gt;
      &lt;/item&gt;
  &lt;/layer-list&gt;
  </code></pre>
  
  <p>Complaining: </p>
  
  <blockquote>
    <p>Binary XML file line #25: <code>&lt;bitmap&gt;</code> requires a valid src attribute</p>
  </blockquote>
  
  <p>An example of one of the drawables, e.g. res/drawable/layer_one.xml:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  
  &lt;!--  res/drawable/layer_one.xml --&gt;
  &lt;shape xmlns:android="http://schemas.android.com/apk/res/android"
      android:shape="rectangle" &gt;
  
      &lt;solid android:color="#FFFFFF"/&gt;
      &lt;corners
          android:bottomRightRadius="15dp"
          android:bottomLeftRadius="15dp"
          android:topLeftRadius="15dp"
          android:topRightRadius="15dp" /&gt;
  &lt;/shape&gt;
  </code></pre>
  
  <p>The example used on the Android site uses images as drawables, not XML-defined shapes (not to say that my error is specific to these, and that I haven't made a silly mistake somewhere). Any clues appreciated, thanks.</p>
  
  <hr>
  
  <p><a href="https://stackoverflow.com/questions/9788726/using-drawable-resources">Using drawable resources</a><br>
  This question's answer states that you cannot use an XML drawable as the src for a Bitmap. I've amended the title of the question, to now ask how you can prevent shapes from scaling (thereby resizing the container view) without using <code>bitmap</code>, or am I forced to use actual image resources?</p>
  
  <hr>
  
  <p>Added an image of the desired outcome - the ability to have a background with a regular rectangle filled shape or whatever, and then layered on top of this, more shape drawables (here there are 3 ellipses). On the left is ideal, where top and left offsets are allowed, and on the right is fine, where all shapes just go to a default position:</p>
  
  <p><img src="https://i.stack.imgur.com/etgJC.jpg" alt="enter image description here"></p>