I want to draw a rectangle as a transparent canvas on my given text
as following image:
I am using following code to draw the transparent rectangle but not able to understand the coordinates position. I tried a lot of time but it's not working.
canvas.drawRect(left,top,right,bottom,paint);
Here is my code:
Paint paint = new Paint();
paint.setAntiAlias(true);
paint.setColor(Color.WHITE);
paint.setStyle(Paint.Style.FILL);
paint.setTextSize(40);
paint.setShadowLayer(2.0f, 1.0f, 1.0f, Color.BLACK);
paint.setAlpha(255);
rectPaint.setAlpha(100);
canvas.drawText("$250", 20, 400, paint);
canvas.drawBitmap(bitmapImage, 490, 55, null);
canvas.drawRect(0, 100, 300, 400, rectPaint);
What would be the value of rest of the coordinates in drawRect
method to align it as given coordinates
of text
. Right now I am using
canvas.drawRect(0, ? , ? , ?, rectPaint);