AppCompat 23.3支持向量不再起作用? [英] AppCompat 23.3 Support Vectors no longer work?

查看:38
本文介绍了AppCompat 23.3支持向量不再起作用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用添加在支持库23.2 以及AppCompat.我在app:srcCompatStateListDrawable内部都使用了矢量可绘制对象,因此我可以在我的TextView中将它们与android:drawableLeft一起使用.

I was using the support vector drawables added in Support Library 23.2 along with AppCompat. I was using vector drawables both with app:srcCompat and inside a StateListDrawable so I could use them with android:drawableLeft for my TextView.

自从升级到AppCompat的23.3.0版本以来,只有app:srcCompat中的向量起作用.每当我以另一种方式引用它

Since upgrading to the 23.3.0 version of AppCompat, only the vectors in app:srcCompat are working. Whenever I reference it the other way I get

FATAL EXCEPTION: main
 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.my.package.name/.MainActivity}: android.view.InflateException: Binary XML file line #8: Error inflating class Button
 ...
 Caused by: android.view.InflateException: Binary XML file line #8: Error inflating class Button
 ...
 Caused by: org.xmlpull.v1.XmlPullParserException: Binary XML file line #14: invalid drawable tag vector
  at android.graphics.d

现在发生了什么变化,导致我的支持向量可绘制对象在某些情况下失败了?

What changed that now causes my support vector drawables to fail in some cases?

推荐答案

更新:他们在支持库23中再次启用了它:

Update: They enable it again in Support Library 23:

对于AppCompat用户,我们添加了一个选择加入API,以通过AppCompatDelegate.setCompatVectorFromResourcesEnabled(true)重新启用来自资源的支持Vector Drawable(行为在23.2中找到); -请记住,这仍然可能导致内存使用问题和更新配置实例的问题,因此为什么默认情况下将其禁用.

For AppCompat users, we’ve added an opt-in API to re-enable support Vector Drawables from resources (the behavior found in 23.2) via AppCompatDelegate.setCompatVectorFromResourcesEnabled(true); - keep in mind that this still can cause issues with memory usage and problems updating Configuration instances, hence why it is disabled by default.

检查此链接:23.4.0现在可用
-------------------------------------------------- ---------

Check this link: 23.4.0 available now
-----------------------------------------------------------

按照 Android支持库23.3的发行公告:

对于AppCompat用户,由于在版本23.2.0/23.2.1中的实现中发现的问题,我们决定删除可用于从棒棒糖设备上的资源中使用矢量绘制工具的功能. https://code.google.com/p/android/issues/detail?id=205236">https://code.google.com/p/android/issues/detail?id=205236 , https://code.google.com/p/android/issues/detail?id=204708 ].继续使用app:srcCompatsetImageResource().

For AppCompat users, we’ve decided to remove the functionality which let you use vector drawables from resources on pre-Lollipop devices due to issues found in the implementation in version 23.2.0/23.2.1 [ https://code.google.com/p/android/issues/detail?id=205236, https://code.google.com/p/android/issues/detail?id=204708 ]. Using app:srcCompat and setImageResource() continues to work.

因此,这是预期的行为更改.对于srcCompat未处理的任何情况,您都必须使用非矢量图形.

So this is an expected behavior change. You'll have to use non-vector graphics for any case not handled by srcCompat.

如果您想在API 21之前继续使用矢量,请您可以删除该行

If you'd like to continue to use vectors prior to API 21, you can remove the line

vectorDrawables.useSupportLibrary = true

(如果您使用的是1.5 Gradle插件,则等价于 23.2博客帖子).

(or the equivalent if you using the 1.5 Gradle plugin as shown in the 23.2 blog post).

这将导致Android Studio在编译时为minSdkVersion小于API 21的应用生成PNG,同时在API 21+设备上使用向量,从而使您可以保持与23.2.1相同的代码,但需要付出额外的代价APK大小.

This will cause Android Studio to generate PNGs at compile time for apps with a minSdkVersion less than API 21 while using your vectors on API 21+ devices, allowing you to keep the same code as with 23.2.1 at the cost of additional APK size.

这篇关于AppCompat 23.3支持向量不再起作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆