title: Android LayerDrawable: How to set layer coordinates programmatically?
body: <p>The following XML code of a layer-list ist given:</p>
  
  <pre><code>&lt;layer-list&gt;
      &lt;item&gt;
          &lt;shape android:shape="rectangle" &gt;
              &lt;solid android:color="@color/my_color_a" /&gt;
          &lt;/shape&gt;
      &lt;/item&gt;
      &lt;item android:left="5dp"&gt;
          &lt;shape android:shape="rectangle" &gt;
              &lt;solid android:color="@color/my_color_b" /&gt;
          &lt;/shape&gt;
      &lt;/item&gt;
  &lt;/layer-list&gt;
  </code></pre>
  
  <p>To do some things dynamically I need to rebuild this code programmatically as a LayerDrawable class. This code exists:</p>
  
  <pre><code>ShapeDrawable layer0 = new ShapeDrawable(new RectShape());
  ShapeDrawable layer1 = new ShapeDrawable(new RectShape());
  LayerDrawable layerDrawable = new LayerDrawable(new Drawable[] {layer0, layer1});
  </code></pre>
  
  <p>How do you translate <code>android:left="5dp"</code> to Java code? There is no setter for this property.</p>