When drawing text on Android's Canvas, using Paint.getTextBounds() alone produces inaccurate centering because the text renders outside its calculated bounds. The fix is to combine Paint.measureText() for width (which accounts for advance width including spacing) with getTextBounds() for height, then offset the draw coordinates accordingly to achieve accurate horizontal and vertical centering.

2m read timeFrom chrisbanes.me
Post cover image
Table of contents
Another text measuring method #
2 Impressions