Stack Exchange
android canvas.drawText in custom view
I have a custom view in which i want to drawText with these parameters.
int stopY = 500;

// ...

Log.info("Drawing line " + line + " at " + String.valueOf(stopY));
canvas.drawText(line, 40, stopY, Paint);

i am having a array of text 
and i am drawing 
 for (int i = startLineNumber; i < (startLineNumber + linesVisible); i++, screenDisplayLine++)
        {
            if (i >= totalLines)
            {
                break;
            }
            int startY = (int) (i*lineSpacing + (screenDisplayLine * lineSpacing));
            int stopY = startY + lineSpacing;
       canvas.drawText(line, 40, stopY, Paint);//stop y increments by 20 every time i use 
    }

it works in straightly but when i needs startnumber as 50 
that mean
 stopy = stopY+(linenumber*20)//(stopY + (50 * 20))

but it fails in this case 
any help 
I can see the correct values in the log through LogCat, but the text is not drawn.
Can anyone help me out?

yes i solved the problem

Thanks to both of your answers; with that I figured out the answer
int stopY = 500;

scrollTo(0,stopY);
canvas.drawText(line, 0, stopY, Paint);

This works fine. As you said  it goes to out-off screen size I used 
scrollTo(0,stopY);

So that it scrolls to that point in the screen and when I used 
canvas.drawText(line, 0, stopY, Paint);

It has drawn it there without any problem.

I think it goes to out-off screen size, use less value for Y and draw.
or
may be problem with paint function 
canvas.drawText(String.valueOf(angle_Top), 15, 25, new Paint());


Thanks i tried it with a new paint() but no luck any other go

i had posted the code for scroll event it works well but if i want to set the first line as 10 line it does not works

@RajaReddyPolamReddy you always want to create Objects outside of the drawing phase, to minimize time it takes to draw, which is a critical phase.

canvas.drawText(String.valueOf(stopY), 40, stopY, Paint);
                ^^^^^^^^^^^^^^^^^^^^^

have you set the color for paint ?
for ex:
mPaint.setColor(Color.RED);

OR 
You are using stopY=500; // may be out of your screen
try to stopY=40; and check output

Thanks but i tried those two but it did't work for me. Any other suggestions? :)
