Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid ViewGroup add child on top of all drawings
    text
    copied!<p>I have a custom <code>ViewGroup</code> where I am overriding it's <code>dispatchDraw</code> and drawing some extra <code>Path</code>s which looks like this :</p> <pre><code>@Override public void dispatchDraw(Canvas canvas) { super.dispatchDraw(canvas); canvas.setMatrix(matrix); mRegions.clear(); canvas.drawPicture(mPicture); if (drawShader) { canvas.drawBitmap(mShader, 0, 0, mBitmapPaint); } for (int i = 0; i &lt; mPaths.size(); i++) { if (mIndex != -1 &amp;&amp; mIndex == i) { canvas.save(); canvas.drawRect(mRect, mPaint); drawPaths(canvas, mPaths.get(i)); canvas.clipPath(mPaths.get(i), Region.Op.INTERSECT); canvas.drawColor(mOverlayColor); Rect f = mRegions.get(i).getBounds(); mPaint.setColor(Color.RED); mPaint.setStyle(Paint.Style.STROKE); canvas.drawCircle(f.centerX() - mRadius, f.centerY() - mRadius, mRadius, mPaint); canvas.restore(); } else { drawPaths(canvas, mPaths.get(i)); } } } </code></pre> <p>Now the things which I want is to add a child which will be placed above these things drawn on <code>dispatchDraw</code>. For now I am doing this :</p> <pre><code> mBalloon = LayoutInflater.from(getContext()).inflate(R.layout.map_balloon, null); LayoutParams params = new LayoutParams(500, 150); mBalloon.setLayoutParams(params); addView(mBalloon); bringChildToFront(getChildAt(0)); </code></pre> <p>in my <code>init()</code> method which is called in my <code>ViewGroup</code>'s constructor and the result is that drawing in <code>dispatchDraw</code> are placed above <code>mBalloon</code>. </p> <p>Any idea how can I place my <code>View - mBalloon</code> above the things from <code>dispatchDraw</code>?</p> <p>Thanks in advance! </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload