Reputation: 1663
I have the following code that works:
protected void onDraw(Canvas canvas) {
canvas.drawRect(undoButtonRectF, buttonPaint);
canvas.drawPath(undoButtonArrow, buttonArrowPaint);
Anyway, when I exchange this with the following:
protected void onDraw(Canvas canvas) {
undoButtonBitmap = Bitmap.createBitmap((int) undoButtonRectF.width(), (int) undoButtonRectF.height(), Bitmap.Config.ARGB_8888);
Canvas ca = new Canvas(undoButtonBitmap);
ca.drawRect(undoButtonRectF, buttonPaint);
ca.drawPath(undoButtonArrow, buttonArrowPaint);
canvas.drawBitmap(undoButtonBitmap, undoButtonRectF.left, undoButtonRectF.top, buttonPaint);
nothing is drawn. How can this happen? Am I using bitmap in a wrong way? Please, help me!!!
Upvotes: 0
Views: 214
Reputation: 6341
I suppose there is a coordinator error.
The error is that undoButtonRectF contains the offsets for "canvas", not for "ca", you should adjust or remove the top/left offset before you call
ca.drawRect(undoButtonRectF, buttonPaint);
ca.drawPath(undoButtonArrow, buttonArrowPaint);
Right ?
Upvotes: 1