Slow App with Background image

koraxis picture koraxis · Jun 27, 2013 · Viewed 14.4k times · Source

I am making a small game for android. It is working smoothly when its working on a white background but when i want to put a background image, its becoming slower and slower. First i tried to add it as a layout background image but it was very slow, the animations were happening frame by frame. And then i decided to draw the background image as a Bitmap on canvas, the result was a little faster than the previous one but still its nothing comparing to the white background.

I tried to scale the image many times, i did it with higher resolution, lower resolution, but the result didnt change, its still slower.

So i wanted to ask, is there a way to add a background image to an android app without losing the smoothness and speed of the application?

Thanks

P.S: I am trying my application on Sony Tablet S

Answer

alp picture alp · Sep 15, 2014

its pretty late but if someone else have the same problem ; on the draw it may try to resize again, you can use no-dpi (drawable-nodpi / drawable-sw600dp-nodpi) folder to skip resizing which requires so much cpu and time.

also something else may cause this , which i assume you forget to recycle old your bitmaps.