您的位置:首页 > 其它

NotFoundException: File res/drawable/abc_vector_test.xml from drawable resourceID

2017-09-15 09:40 2046 查看
华为手机碰到的问题记录-NotFoundException:File res/drawable/abc_vector_test.xml from drawable resource ID
后来在build gradle中加入了
aaptOptions {
       additionalParameters "--no-version-vectors"
    }
然后就ok了。

Android Support Library 23.2有哪些新东西

应该意识到这不是一个库,而是一套库的集合 ,它们旨在无需新平台的情况下,提供API的向后兼容版本以及新功能。  23.2 版本添加了一些新的支持库,同时还为现有的库增加了新特性。
  支持Vector Drawable 和 Animated Vector Drawable
  Vector drawables 让自己可以用一个定义在XML里的矢量图象替换多个png资源。而之前这一用法只局限于Lollipop以及更高的设备,VectorDrawable和AnimatedVectorDrawable现在可以分别通过两个新的支持库support-vector-drawable 和 support-animated-vector-drawable得到。
  Android Studio 1.4 中介绍了一种通过 在编译时生成png 的办法对vector drawable提供了有限的支持。为了禁用这个功能(节省支持库的空间,真正受益于新的库),需要在 build.gradle文件里添加vectorDrawables.useSupportLibrary = true :
  // Gradle Plugin 2.0+
  android {
  defaultConfig {
  vectorDrawables.useSupportLibrary = true
  }
  }

  需要注意这个新的属性只有2.0版本的Gradle Plugin中才有。如果正在使用Gradle 1.则应该使用
  // Gradle Plugin 1.5
  android {
  defaultConfig {
  generatedDensities = []
  } 
  // This is handled for you by the 2.0+ Gradle Plugin
  aaptOptions {
  additionalParameters "--no-version-vectors"
  }
  }
  可以使用兼容到API7的VectorDrawableCompat和兼容到API11或者更高的AnimatedVectorDrawableCompat。鉴于安卓加载drawable的方式,并不是每个接受drawable id的地方(比如在一个XML文件中)都支持加载vector drawable。幸好,AppCompat 添加了几个功能让自己更容易使用新的vector drawable。
  首先,当自己和ImageView(或者例如 ImageButton 和 FloatingActionButton这样的子类) 一起使用AppCompat的时候,可以使用新的app:srcCompat属性来饮用 vector drawable(而任何其它drawable则用 android:src):
  <ImageView
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  app:srcCompat="@drawable/ic_add" />
  并且,如果要在运行时动态的改变drawable,可以使用和之前相同的 setImageResource() 方法 - 这点并没有变。使用AppCompat和app:srcCompat是在app中集成vector drawable最简单可靠的方式。
  会发现在Lollipop之前直接在app:srcCompat之外引用vector drawable会失败。但是AppCompat却支持其它drawable 容器比如StateListDrawable, InsetDrawable, LayerDrawable, LevelListDrawable, 或者 RotateDrawable加载vector drawable。使用这种间接的方法,可以在这种情况下使用vector drawable,比如TextView的 android:drawableLeft 属性,本来在正常情况下,它是不支持vector drawable的。
  AppCompat夜间白天主题
  虽然在能各个版本的app中使用矢量图像已经是一个很大的变化了,但是这个版本还在AppCompat中添加了一个新主题:Theme.AppCompat.DayNight。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐