why my invoke of Canvas.drawText() just doesn't work

android, android-canvas, drawtext, ondraw, textview

Solution

It isn't drawing anything because the text coordinates are bottom left. Since you're trying to draw on 0,0, it will draw above the screen.

Try changing the last line to:

canvas.drawText(text, 0, 20, paint);

Problem

Hi all: I'm writing a class that inherit from TextView, and override its `onDraw()` method, but in the method, my invoke of `canvas.drawText()` doesn't seems to work, the code just like below: ``` protected void onDraw(Canvas canvas) { // super.onDraw(canvas); Paint paint = new Paint(); paint.setColor(android.graphics.Color.WHITE); paint.setTextSize(20); String text = "hello"; canvas.drawText(text, 0, 0, paint); } ```

Original source