开发者

background (image) in canvas while drawing path over the top

@Override protected void onDraw(Canvas canvas) {

        if (mBitmap != null) {

            canvas.drawColor(0xFFAAAAAA);

            canvas.drawBitmap(background,0,0,mBitmapPaint);

            if(isRelevant){
                canvas.drawBitmap(mBitmapLast, 0,0, mBitmapLastPaint);
            }

            canvas.drawBitmap(mBitmap, 0, 0, mBitmapPaint);
                canvas.dr开发者_如何学CawPath(mPath, mPaint);
        }
    }

I've tried switching around the lines

canvas.drawColor(0xFFAAAAAA);
                canvas.drawBitmap(background,0,0,mBitmapPaint);

and when canvas.drawColor(0xFFAAAAAA); is second, my paths will show up when I draw them on the screen. Is there a way to make the background (bitmap) show underneath the canvas paths?


Try setting the Xfermode in your Path's paint:

mPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_OVER));  // or DST_OVER

and see PorterDuff.Mode explained.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜