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

前端 未结 4 1777
既然无缘
既然无缘 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:24

    Sorry for my bad English

    I had the same problem, if you put any "xml" files into "drawable-24" just move them to "drawable", this was the solution that i did to solve this problem

    have a nice day :)

    0 讨论(0)
  • 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.

    0 讨论(0)
  • 2020-12-01 16:39

    As the others clarified, part of a problem was an issue related to the background image I'd set for my layout. However, getting that solved, I persistently encountered the error:

    Unfortunately the application has stopped

    With trial and error, I found the problem was caused by the <view> elements which after deleting them, I could eventually run the application.

    0 讨论(0)
  • 2020-12-01 16:42

    please follow background image size

    for Supported device

    LDPI:
    Portrait: 200x320px
    Landscape: 320x200px
    MDPI:
    Portrait: 320x480px
    Landscape: 480x320px
    HDPI:
    Portrait: 480x800px
    Landscape: 800x480px
    XHDPI:
    Portrait: 720px1280px
    Landscape: 1280x720px
    
    0 讨论(0)
提交回复
热议问题