Android向量相容性

编程入门 行业动态 更新时间:2024-10-14 06:24:57
本文介绍了Android向量相容性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我想开始在我使用的应用程序中使用矢量作为图标,但是不确定如何处理兼容性

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向量相容性

本文发布于:2023-11-17 02:44:19,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1608519.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:相容性   向量   Android

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!