VectorDrawable:Android的负载xhdpi PNG的,而不是矢量资源 [英] VectorDrawable: Android loads xhdpi PNG's instead of the vector resource
问题描述
我试图使用 VectorDrawable
上API21,而Android加载从 xxhdpi
文件夹中的PNG资源,而不是。
我现在 RES
结构如下:
I'm trying to use a VectorDrawable
on API21, but Android loads the PNG resource from xxhdpi
folder instead.
My current res
structure as follows:
- 资源
- 绘制-xxhdpi
- test_icon.png
- test_icon.xml
和我的XML布局:
<ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/test_icon"/>
还有没有其他的办法来解决这个?从我的理解Android将永远挑PNG资源,但如果是这样的话,我们可以如何使用
VectorDrawables
为API21
和PNG较低的API?Are there any other ways to solve this? From my understanding Android will always pick the PNG resource, but if that's the case, how one can use
VectorDrawables
forAPI21
and PNG for lower API's?[更新1]
如果我们使用
绘制-xxhdpi-21
资源文件夹,Android将挑选载体,而不是PNG资源。但是,这意味着我们将不得不对其他密度的文件的副本(或符号连接),以及(如xhdpi
,华电国际
等)If we use a
drawable-xxhdpi-21
resource folder, Android will pick the vector instead of the PNG resource. But that means we would have to have a copy (or symlink) of the file for other densities as well (e.g.xhdpi
,hdpi
, etc)推荐答案
绘制-anydpi-V21是正确的为
drawable-anydpi-v21 is right for that
drawable-anydpi-v21/test_icon.xml
https://google.github.io/material-design -icons /#图标换机器人
这篇关于VectorDrawable:Android的负载xhdpi PNG的,而不是矢量资源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
- 绘制-xxhdpi