I searched for many hours and could not find a clear answer to my question. I have an application where I need to draw a sports field (including all tonal lines) on the screen. So far, I have expanded SurfaceView and pretty much copied the rest of the demo version of LunarLander. All the data that the application requires in order to pull the pitch to the right sizes comes from a socket that works great. However, per minute, in the onDraw () function, I draw all the lines of each frame, which causes a rather slow frame rate in the emulator (for example, ~ 10 frames per second). Here is my onDraw () function:
@Override
public void onDraw(Canvas canvas) {
canvas.drawARGB(255,0,144,0);
canvas.drawLine(canvas, getFirstLine(), mPaint);
canvas.drawRect(canvas, getFirstRect(), mPaint);
canvas.drawRect(canvas, getSecondRect(), mPaint);
...
canvas.drawRect(canvas, getSecondRect(), mPaint);
drawAnimatedObjects();
}
Then I draw circles and different positions against this background. My question is how to make this more efficient? Is there a way I can draw lines when initializing an application and not redraw them every frame?
Thanks for any help.
source
share