InflateException: Binary XML file line #8: Error inflating class ImageView

前端 未结 14 2029
忘掉有多难
忘掉有多难 2020-12-03 06:56

I know there are other questions on SO asking the same thing. I have already looked at most of them.

Most answers call about memory errors. I can\'t see how an

相关标签:
14条回答
  • 2020-12-03 07:14

    binary xml file line #0: error inflating class imageview

    you have to see if your image has become drawable-v23 or v24 which might be higher than your mobile os level, Make sure to avoid creating drawable version image in project

    example In drawable folder ~> "ic_contact(v24)"

    0 讨论(0)
  • 2020-12-03 07:16

    using android.support.v7.widget.AppCompatImageView without android:background solved the problem for me.

    0 讨论(0)
  • 2020-12-03 07:19

    The following code might be added in Android Manifests-Activity

    <activity
    android:name=""
    --------------
    android:theme="@android:style/Theme.Black.NoTitleBar">
    </activity>
    

    please remove this theme if you have added.

    My problem has been solved after removing this theme. I got these solution after long time.

    0 讨论(0)
  • 2020-12-03 07:21

    I had the same problem. The png image for my imageView was causing a class inflateException. This was only happening with my phone running android 6.0.1, but not in my phone running android 7.0. To solve this:

    ---In Android Studio---

    • Deleted the png image from the drawable folder (I only have the drawable folder visible, not the drawable-v24).
    • Copy the png back to the drawable folder. When doing this, you'll be able to pick to copy it to either the drawable or drawable-v24 folder. Copy the png to both folders
    • Copy the png to both folders (png's must have same name).
    • Once you copy the png to both folders, a new folder with the png's name will show up. Inside it you will see the 2 png's. One with "(v24)" next to it. New folder with name of png's will appear, containing png's
    0 讨论(0)
  • 2020-12-03 07:22

    If you are using vector drawables, use

    app:srcCompat="@drawable/ic_dot"
    

    instead of

    android:src="@drawable/ic_dot"
    
    0 讨论(0)
  • 2020-12-03 07:27

    Don't paste your image into drawable in Android studio, paste it into the drawable folder and clean the project and then run it will work.

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