如何创建 android:pathData? [英] how to create android:pathData?

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

问题描述

所以我需要在我的应用程序中使用路径数据,有没有办法将您已经拥有的图像转换为路径数据?

so i'm going to need to use path data in my app, is there a way to convert images you already have to path data ?

或者唯一的方法是自己使用 Photoshop 等实际计算所有像素.?

or the only way is to actually calculate all the pixels yourself using Photoshop etc.. ?

推荐答案

假设你指的是 VectorDrawable 的 pathData 元素,如果你有 .svg 格式的图像,你可以转换它们很容易.

Assuming you're referring to the pathData element of a VectorDrawable, if you have the images in .svg format you can convert them easily.

直接在 Android Studio 中通过右键单击可绘制文件夹然后新建>矢量资源并导入您的本地 SVG 文件来执行此操作:

Either do it directly in Android Studio by right-clicking on the drawable folder then New>Vector Asset and import your local SVG file:

或者使用其他转换器,例如 svg2android(您可能会发现这适用于 Android Studio 无法处理的文件转换).

Or use another converter like svg2android(you might find this works on files that Android Studio fails to convert).

如果您不想要 VectorDrawable 而只想获取 pathData,您可以在文本编辑器中打开一个 SVG.如果您拥有的图像不是矢量格式,事情会更加困难.

If you don't want a VectorDrawable and just want to get the pathData you can open an SVG in a text editor. If the images you have aren't in a vector format already things will be more difficult.

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

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