以XML定义的Android Drawable可以包含路径吗? [英] Can Android Drawables defined in XML contain a path?

查看:86
本文介绍了以XML定义的Android Drawable可以包含路径吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Inkscape在我的应用程序中创建艺术品.

I use Inkscape to create the art assets in my app.

目前,我必须先使用(简单的)Inkscape矢量艺术创建位图,然后才能在应用程序中使用图像.

At the moment I have to create bitmaps from my (simple) Inkscape vector art before I can use the images in my app.

我希望能够创建一个包含我作品路径的XML Drawable.能做到吗?

I would prefer to be able to create an XML Drawable that contains the paths from my art. Can this be done?

推荐答案

随着 Android 5.0 Lollipop (API 21)的发布,现在可以使用

With the release of Android 5.0 Lollipop (API 21) this is now possible using VectorDrawable

<vector xmlns:android="http://schemas.android.com/apk/res/android"
     android:height="64dp"
     android:width="64dp"
     android:viewportHeight="600"
     android:viewportWidth="600" >
     <group
         android:name="rotationGroup"
         android:pivotX="300.0"
         android:pivotY="300.0"
         android:rotation="45.0" >
         <path
             android:name="v"
             android:fillColor="#000000"
             android:pathData="M300,70 l 0,-70 70,70 0,0 -70,70z" />
     </group>
 </vector>

这篇关于以XML定义的Android Drawable可以包含路径吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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