Skip to content Skip to sidebar Skip to footer

Improve Draw Background Performance

I'm drawing a background (a grid) in a View, basically all the screen filled with triangles (note I need to draw the triangles), but it seems to get the application slower. Is the

Solution 1:

After lots of trial and error the solution I found was doing the custom drawing on the OnSizeChanged event of a FrameLayout instead of OnDraw so that the code is only exectued once. In the OnSizeChanged event I draw the background in a temporary canvas, set it into a bitmap, created a BitmapDrawable for it and call setBackgroundDrawable with the BitmapDrawable. After that I do the custom drawing and paint it into a bitmap to which is set to a custom ImageView which can be zoomed and scrolled while performance is not affected. Custom ImageView is similar to the example I posted here.


Post a Comment for "Improve Draw Background Performance"