如何为android创建矢量绘图? [英] How to create vector drawables for android?

查看:38
本文介绍了如何为android创建矢量绘图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 VectorDrawables 的新手.

我可以看到 android studio 提供的默认 vector drawables,如 ic_menu_galleryic_menu_camera 等,效果很好.所以我尝试通过首先将我的 png 图像 转换为 svg 并使用路径和填充值来制作矢量可绘制对象来创建我自己的 vector drawables,即替换 android:pathData 用于 d 和 android:fillColor 用于 svg 文件中的填充标记.它以某种方式提供了矢量可绘制对象,但看起来扭曲或粗糙.

I can see that the default vector drawables provided with android studio like ic_menu_gallery, ic_menu_camera, etc. are working great. So I tried to create my own vector drawables by converting my png images to svg first and using the path and fill values to make vector drawables i.e replaced the android:pathData for d and android:fillColor for fill tag in svg files. It somehow gave vector drawables but distorted or currputed looking.

如果我没有采取正确的方法,请给我建议.

If I am not taking the right approach please suggest me.

推荐答案

您可以使用 Android Studio.将 png 转换为 svg 文件在线工具

You can use Android Studio. Convert png to svg file online tools PNG to SVG

对于 SVG 颜色可以使用:

For SVG color can use :

  <ImageButton
    android:layout_width="48dp"
    android:layout_height="48dp"
    android:id="@+id/button"
    android:src="@drawable/ic_more_vert_24dp"
    android:tint="@color/primary" />

imageView.setColorFilter(getResources().getColor(android.R.color.black), PorterDuff.Mode.SRC_IN);

可以将SVG转换为PNG的在线工具:coolutils

Can convert SVG to PNG online tool: coolutils

将 SVG 转换为 Android drawable:内循环

Convert SVG to Android drawable: inloop

这篇关于如何为android创建矢量绘图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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