我使用Illustrator创建了一个简单的播放按钮图像,将其保存为SVG格式,使用在线SVG-to-Drawable转换器创建了文件的xml,然后试着使用Android Studio的Vector Asset工具将文件导入到我的项目中。但是,在导入时,drawable的一个元素丢失了,例如圆圈中间的白色三角形。
play_circle.xml(转换后的xml文件)
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:viewportWidth="94"
android:viewportHeight="102"
android:width="94dp"
android:height="102dp">
<path
android:pathData="M85 52.5A38.5 38.5 0 0 1 46.5 91 38.5 38.5 0 0 1 8
52.5 38.5 38.5 0 0 1 46.5 14 38.5 38.5 0 0 1 85 52.5Z"
android:strokeWidth="2"
android:fillColor="#424900"
android:strokeAlpha="0.29"
android:fillAlpha="0.29"
android:strokeColor="#000000"
android:strokeMiterLimit="10" />
<path
android:pathData="M71.39 51.63L34.81 30.51"
android:fillColor="#ffffff" />
</vector>
play_button.svg是使用Illustrator创建的,这是它的原始样子。
在导入Android Studio后,它的外观发生了变化。通过使用Android Studio的矢量素材工具,你可以看到白色三角形已经消失了。