Reputation: 118
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?
Upvotes: 1
Views: 1691
Reputation: 118
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.
Upvotes: 1
Reputation: 22493
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());
Upvotes: 2
Reputation: 15847
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
Upvotes: 1