Although this question is old, I just ran into one problem and found a solution as follows: maybe it can help someone else:
Subclass TextView and redefine it onDraw() as follows:
// bounds field to avoid allocations in onDraw() Rect bounds = new Rect(); @Override protected void onDraw(Canvas canvas) { getPaint().getTextBounds(getText().toString(), 0, getText().length(), bounds); canvas.translate(-bounds.left, 0); super.onDraw(canvas); }
Caveat . Although I observed that the borders of the text have a left value corresponding to the number of empty pixels before the first letter, and corresponds to the documentation Paint#getTextBounds() , which states: what it returns
the smallest rectangle that spans all characters, with an implied beginning at (0,0),
thus, the left value is where the actual text begins; this hotfix may not work for all fonts or configurations.
It should also be noted that this is a simple solution for text with single-line left justification; multiline or scrolled text will need additional adjustments or may not work with it at all.
source share