Slow App with Background image

后端 未结 7 1209
情话喂你
情话喂你 2021-02-01 03:19

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. Fi

相关标签:
7条回答
  • 2021-02-01 03:37

    Recently i had the same issue and no answer helped me.But after playing with codes so many hours i found an amazing solution.What you have to do is copy your background image to all the drawable folders (drawable-hdpi,drawable-xhdpi...etc.) and thats it. And also my background image is png with 590kb file size. Be careful with image size because higher the size is slower the app. Hope this help to someone. :-)

    0 讨论(0)
  • 2021-02-01 03:40

    The main reason you're noticing the lag is because the image needs to because you need to copy your background image to all the drawable folders (drawable-hdpi,drawable-xhdpi...etc.) . I use the Android Studio plugin named Android Drawable Importer for automating. Works like a charm.

    0 讨论(0)
  • 2021-02-01 03:44

    For excellent performance use tiled background you can find nice explanation for it here

    0 讨论(0)
  • 2021-02-01 03:51

    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.

    0 讨论(0)
  • 2021-02-01 03:53

    I was in the same position as you. I have a very simple app and it has lags when i add some background. Try this app 9-patch-resizer - Transform the image dimensions for all screens

    And then comes this tool, that takes a xhdpi PNG file, or 9.png file, and generates ldpi, mdpi and hdpi png files automatically.

    When it transoforms the image , move the each file to its own project folder (resources/mipmap-hdpi ,mipmap-xhdpi ...etc)

    0 讨论(0)
  • 2021-02-01 03:56

    Background image Resolution to maintain smoothness

    DPI Size in Pixels
    xxxhdpi 1280x1920
    xxhdpi 960x1600
    xhdpi 640x960
    hdpi 480x800
    mdpi 320x480
    ldpi 240x320

    You need to use background pictures matching the resolution as above to avoid lagging or being slow down.!

    If you use high resolution images which exceeds the above restrictions would actually cause this issue and it's advisable to use only png

    0 讨论(0)
提交回复
热议问题