我想开始在我使用的应用程序中使用矢量作为图标,但是不确定如何处理兼容性
I'd like to start using vectors for the icons with in the apps I do, but not sure how to deal with the compatibility
我对任何第三方兼容库都不感兴趣,很高兴等待google版本(此处提及 VectorDrawable-它可用于Android的Lollipop之前版本吗?).
I'm not interested in any of the third party compat libraries and happy to wait for googles version (Mentioned here VectorDrawable - is it available somehow for pre-Lollipop versions of Android?).
所以基本上到目前为止,我很高兴继续获得每个分辨率的图像以及Lollipop的其他图像.如果设备高于21,则将使用矢量,否则将退回到标准png.
So basically for now I'm happy to continue to have the images per resolution as well as an additional for > Lollipop. If the device is higher than 21 it will use the vector otherwise it will fall back to the standard png's.
我可以将矢量放置在drawable-v21文件夹中,但是drawable- [dpi]文件夹优先于版本,这意味着不使用矢量.
I can have the vector in a drawable-v21 folder, but the drawable-[dpi] folder takes precedence over the version, meaning the vector isn't used.
我希望使用该向量,以便当compat可用时,我可以简单地删除所有png并知道这些向量是可以的,因为我已经能够在运行Lollipop的设备上对其进行测试.
I'm hoping the vector is used so that when the compat comes available I can simply delete all the png's and know the vectors will be ok as I have been able to test them on a device running Lollipop.
推荐答案从Android 5.0(API级别21)开始,您可以在应用程序中使用vector drawable.您可以使用新的Android Studio工具,称为:Vector Asset Studio.它会自动处理旧版本的PNG.请参阅下面的链接以获取完整说明:
From Android 5.0 (API level 21) you can use vector drawable in your app. You can use new Android Studio tool called: Vector Asset Studio. It handles PNG making for older versions automatically. See link below for a complete explanation:
Vector Asset Studio
更多推荐
Android向量相容性
发布评论