Im trying to draw a text at the coordinate 0,0 on a Bitmap using the code
canvas.drawText(text, 0, 0, paint);
but the text is drawn outside the image,the text only appears when i try some 20,25 values.Why is this? isnt this code supposed to draw text at 0,0 i had tried (0.0f,0.0f)
no luck.
The Y coordinate is for the text baseline, not the top. If you want the text top to be at y=0, do something like
FontMetrics fm = paint.getFontMetrics();
canvas.drawText(text, 0 /*x*/, 0 /*y*/ - fm.ascent, paint);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.