title: How to combine shape drawable and drawable into single drawable
body: <p>I am generating shape drawable and drawable runtime in android programmatically. What all I need is to combine two drawable into single drawable. I tried to implement through following methods, but nothing seems to work out.</p>
  <p><strong>Sample code to combine two drawables into single using LayerDrawable</strong></p>
  <pre><code>public static LayerDrawable drawCircleWithIcon (Context context, int width, int height, int color,Drawable drawable) {
  
          ShapeDrawable oval = new ShapeDrawable (new OvalShape ());
          oval.setIntrinsicHeight (height);
          oval.setIntrinsicWidth (width);
          oval.getPaint ().setColor (color);
  
          Drawable[] layers = new Drawable[2];
          layers[0] = drawable;
          layers[1] = oval;
  
          LayerDrawable composite1 = new LayerDrawable (layers);
  
          return composite1;
      }
  </code></pre>
  <p><strong>Arguments I am passing:</strong></p>
  <pre><code>width - width of the circle  
  height - height of the circle  
  color - color of the circle
  drawable - icon that needs to be fit inside the ShapeDrawable (i.e. Round circle inside placed with icon) 
  </code></pre>
  <p><strong>My requirement:</strong></p>
  <p>I need to combine two drawables (one is ShapeDrawable and drawable). The output must be like as following</p>
  <p><a href="https://i.stack.imgur.com/rQcay.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/rQcay.png" alt="enter image description here" /></a></p>
  <p>Kindly please help me with your solutions or alternate methods to merge two drawable into one drawable icon. Thanks in advance.</p>