可绘制的矢量调整不正确

时间:2017-10-25 21:58:44

标签: android svg vector adobe-illustrator android-vectordrawable

我在Adobe Illustrator创建了徽标,将其导出为SVG,然后通过Asset Studio将其导入Android Studio。

当矢量被绘制得很大时,它会被正确调整大小(图像1),但是当它很小(图像2)时,会出现问题。

Big vector Little vector

两者都是ImageView,第二个是Toolbar

这是矢量:

<vector
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:height="24dp"
    android:viewportHeight="128.0"
    android:viewportWidth="128.0"
    android:width="24dp" >
    <path android:fillColor="#7c7c7c" android:pathData="M64,64m-64,0a64,64 0,1 1,128 0a64,64 0,1 1,-128 0"/>
    <path android:fillColor="#0b5c5d" android:pathData="M63.91,63.91m-57.6,0a57.6,57.6 0,1 1,115.2 0a57.6,57.6 0,1 1,-115.2 0"/>
    <path android:fillColor="#fff" android:pathData="M77.31,16.23s-25.13,0.69 -40.7,5.59c-24.64,8.76 -23.73,45.63 -6.94,56C35.88,82.05 61.59,80 61.59,80l5.32,-15.27s-17.23,5.49 -28.67,-1.47C34.3,61.12 31.87,44 40,36.94S75.16,33.3 75.16,33.3Z"/>
    <path android:fillColor="#fff" android:pathData="M51.87,43c15.77,2.66 54.59,-3.2 55.95,-3.53 1.56,-0.39 -23.14,37.71 -29,51.92A73.06,73.06 0,0 0,105.28 90s-4.91,12.15 -4.88,16.64c-7.3,-1.58 -41.33,-4.25 -50.87,-3 4.3,-4.55 27.39,-38.13 31.4,-47 -12.16,0.39 -17.8,-0.47 -33.51,0.06C49.18,53.29 51.6,49.79 51.87,43Z"/>
</vector>

我不知道发生了什么。

SVG导出Adobe Illustrator时我尝试更改小数计数,将文档大小调整为更大更小以及对话框中的其他设置。

2 个答案:

答案 0 :(得分:0)

您好请检查我的下面的代码我已经用实际检查这个,我得到了正确的输出。

    <android.support.v7.widget.Toolbar
        android:layout_width="match_parent"
        android:layout_height="60dp"
        android:background="@color/black_overlay">

        <ImageView
            android:id="@+id/button"
            android:layout_width="50dp"
            android:layout_height="50dp"
            android:layout_gravity="center"
            app:srcCompat="@drawable/your_drawable" />


    </android.support.v7.widget.Toolbar>

如果你正在使用工具栏的其他布局,那么将那些工具栏包含在那些工具栏之间就可以了。

如果您在此尝试后仍有问题,请将您的xml代码放入,以便我可以检查并解决您的问题。

答案 1 :(得分:0)

根据您的drawable xml

您必须创建此drawable的副本才能在工具栏中使用,对于此工具栏,您必须使用工具栏高度和宽度来缩小视图端口大小。

android:viewportHeight="YOUR TOOLBAR HEIGHT"
android:viewportWidth="YOUR TOOLBAR HEIGHT (to make it square)"