title: Drawing LinearLayout with rounded corners
body: <p>I'm trying to implement a LinearLayout subclass that draws itself with rounded corners. From my research, I set <code>setWillNotDraw(false)</code> and overridden <code>onDraw()</code> to draw a rounded rectangle in the canvas:</p>
  
  <pre><code>@Override
  protected void onDraw(Canvas canvas) {
      super.onDraw(canvas);
  
      int sc = canvas.saveLayer(0, 0, getWidth(), getHeight(), drawPaint, Canvas.MATRIX_SAVE_FLAG | Canvas.CLIP_SAVE_FLAG | Canvas.HAS_ALPHA_LAYER_SAVE_FLAG
              | Canvas.FULL_COLOR_LAYER_SAVE_FLAG | Canvas.CLIP_TO_LAYER_SAVE_FLAG);
      canvas.drawRoundRect(bounds, mCornerRadius, mCornerRadius, roundPaint);
      canvas.restoreToCount(sc);
  }
  </code></pre>
  
  <p>where:</p>
  
  <pre><code>drawPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
  drawPaint.setColor(0xffffffff);
  drawPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.DST_IN));
  
  roundPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
  roundPaint.setColor(0xffffffff);
  </code></pre>
  
  <p><code>DST_IN</code> seems the correct option here (according to the APIDemos example), but the area that should be transparent (the rounded one) has instead a black background, and the corners of the children are still visible. This is the result on a Galaxy Nexus with Android 4.2.2:</p>
  
  <p><img src="https://i.stack.imgur.com/V92Js.png" alt="example"></p>
  
  <p>Any hints?</p>
  
  <p>EDIT: Here is what I'd like to achieve, sorry for the crudeness of photoshopping :)</p>
  
  <p><img src="https://i.stack.imgur.com/cZfNv.png" alt="enter image description here"></p>
  
  <p>EDIT 2: I added to GitHub an example runnable project: <a href="https://github.com/venator85/RoundClippingLayout" rel="noreferrer">https://github.com/venator85/RoundClippingLayout</a></p>
  
  <p>Thanks ;)</p>