当前位置: 代码迷 >> 综合 >> android.view.InflateException: Binary XML file line #0: Error inflating class ImageView报错
  详细解决方案

android.view.InflateException: Binary XML file line #0: Error inflating class ImageView报错

热度:63   发布时间:2023-11-29 15:53:11.0


报错:PID: 6851  android.view.InflateException: Binary XML file line #0: Error inflating class ImageView



解决:

1、最外层布局添加: xmlns:app="http://schemas.android.com/apk/res-auto"


2、使用app:srcCompat 接收Vector

    <ImageViewapp:srcCompat="@drawable/ic_navigate_next_black_24dp"android:layout_gravity="center"android:layout_marginRight="8dp"android:layout_width="24dp"android:layout_height="24dp" />


3、添加 vectorDrawables.useSupportLibrary = true

defaultConfig {。。。vectorDrawables.useSupportLibrary = true}





参考:https://chris.banes.me/2016/02/25/appcompat-vector/#enabling-the-flag





  相关解决方案