android.view.InflateException: Binary XML file line #2: Error inflating class

前端 未结 4 1793
既然无缘
既然无缘 2020-12-01 16:18

I am developing a simple app. Just finished the home screen. If the orientation changes more than two times, it is throwing the error and application is force closing.

4条回答
  •  眼角桃花
    2020-12-01 16:30

    At runtime, Android resize's images based on need (based on the screen size and resolution). It uses Bitmap's for doing the resizing internally. Which, obviously, is very memory intensive (kinda allocates memory like crazy). One quick way to fix such issues can be, that you copy all drawable files to drawable-ldpi, mdpi, hdpi folders. This way android will just pick up the files from these folders and not resize them.

    Its a random kind exception, a real pain to fix.

提交回复
热议问题