Vector drawable distorted

一曲冷凌霜 提交于 2021-02-09 04:03:27

问题


I have many imageviews that use a vector drawable as it's source. For most of them it's material icons but when I imported a more complicated vector it shows up distorted on Lollipop devices but just fine on Jellybean devices. This is supposed to say SYSTEMS but clearly has problems.

vector

Layout:

<ImageView
android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/splash_logo"
        app:srcCompat="@drawable/logo_small"
        tools:ignore="MissingPrefix"
        android:layout_centerVertical="true"
        android:layout_marginRight="20dp"
        android:layout_alignParentRight="true" 
        android:layout_alignParentEnd="true" />

Gradle build file:

defaultConfig {
    applicationId "com.android.example"
    minSdkVersion 16
    targetSdkVersion 23
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    generatedDensities = []
}

aaptOptions {
    additionalParameters "--no-version-vectors"
}

Vector drawable:

<vector xmlns:android="http://schemas.android.com/apk/res/android"
    android:width="160dp"
    android:height="40dp"
    android:viewportWidth="432.0"
    android:viewportHeight="108.0">
<path
    android:pathData="M247.77,92.34a4.5,4.5 0,0 0,4 2.09c2.26,0 3.64,-1.3 3.64,-2.91 0,-3.68 -8,-2.1 -8,-6.81 0,-2.22 2.14,-3.79 5.52,-3.79a6.67,6.67 0,0 1,3.76 0.94,5.37 5.37,0 0,0 -0.69,1.68h-0.3a3.1,3.1 0,0 0,-3 -1.88c-1.91,0 -3.28,1 -3.28,2.48 0,3.75 8,2.18 8,6.61 0,2.45 -2.31,4.51 -6.23,4.51a7.26,7.26 0,0 1,-4.2 -1.14,4.84 4.84,0 0,0 0.48,-1.78h0.31Z"
    android:fillColor="#fff"/>
<path
    android:pathData="M266.2,81.18a9.57,9.57 0,0 0,2.79 0c1.48,2.28 3.08,4.55 4.83,6.93a65,65 0,0 0,4.81 -6.93,4.85 4.85,0 0,0 2,0 99.26,99.26 0,0 0,-6.15 7.91c0,2 0.08,4.67 0.2,5.91a7.92,7.92 0,0 0,-2.49 0,46.6 46.6,0 0,0 0.2,-5.69C271.36,87.93 267.27,82.44 266.2,81.18Z"
    android:fillColor="#fff"/>
<path
    android:pathData="M290.21,92.34a4.5,4.5 0,0 0,4 2.09c2.26,0 3.64,-1.3 3.64,-2.91 0,-3.68 -8,-2.1 -8,-6.81 0,-2.22 2.13,-3.79 5.52,-3.79a6.69,6.69 0,0 1,3.77 0.94,5.28 5.28,0 0,0 -0.69,1.68h-0.31a3.1,3.1 0,0 0,-3 -1.88c-1.91,0 -3.28,1 -3.28,2.48 0,3.75 8,2.18 8,6.61 0,2.45 -2.32,4.51 -6.23,4.51a7.24,7.24 0,0 1,-4.19 -1.14,4.92 4.92,0 0,0 0.48,-1.78h0.3Z"
    android:fillColor="#fff"/>
<path
    android:pathData="M314.11,86.37q0,-2.07 -0.08,-4.15c-1.75,0 -4,0.08 -5.44,0.22a1.8,1.8 0,0 0,0.13 -0.64,1.91 1.91,0 0,0 -0.13,-0.62c2.19,0.06 4.37,0.1 6.56,0.1s4.38,0 6.56,-0.1a2,2 0,0 0,-0.13 0.64,1.85 1.85,0 0,0 0.13,0.62c-1.42,-0.14 -3.69,-0.22 -5.44,-0.22q-0.08,2.07 -0.08,4.15v3.45c0,1.72 0.1,3.47 0.2,5.19a9.29,9.29 0,0 0,-1.25 -0.1,9.19 9.19,0 0,0 -1.25,0.1c0.1,-1.72 0.2,-3.46 0.2,-5.19V86.37Z"
    android:fillColor="#fff"/>
<path
    android:pathData="M331.8,86.35c0,-1.72 -0.1,-3.47 -0.2,-5.17 1.52,0.06 3,0.1 4.55,0.1s3,0 4.53,-0.1a2.39,2.39 0,0 0,0 1.2c-2.13,-0.12 -3.38,-0.26 -6.69,-0.26 0,0.86 -0.1,1.56 -0.1,2.54s0,2.14 0,2.65c3,0 4.68,-0.1 6.18,-0.2a2.66,2.66 0,0 0,-0.08 0.62,2.5 2.5,0 0,0 0.08,0.6c-1.76,-0.14 -5,-0.18 -6.18,-0.18 0,0.48 0,1 0,2.91 0,1.52 0,2.5 0,3a58.72,58.72 0,0 0,6.87 -0.26,2.54 2.54,0 0,0 -0.08,0.62 2.22,2.22 0,0 0,0.08 0.58c-1.5,-0.06 -3,-0.1 -4.58,-0.1s-3.07,0 -4.62,0.1c0.1,-1.74 0.2,-3.49 0.2,-5.21V86.35Z"
    android:fillColor="#fff"/>
<path
    android:pathData="M353.24,80.92c2.31,3.77 4.7,7.29 7.3,11 1,-1.56 5.06,-7.33 7.55,-11h0.33c0.76,5.13 1.27,9.5 2.08,14.08a7.29,7.29 0,0 0,-2.39 0c-0.36,-3.59 -0.71,-6.91 -1.24,-10.34h-0.05c-2.31,3.35 -4.65,6.63 -6.66,10.24h-0.23c-2,-3.32 -4.32,-6.77 -6.53,-10.24h-0.05c-0.48,3.31 -1.19,8.08 -1.22,10.34a4.06,4.06 0,0 0,-1.78 0c0.89,-4.43 1.91,-9.84 2.47,-14.08h0.43Z"
    android:fillColor="#fff"/>
<path
    android:pathData="M380.75,92.34a4.51,4.51 0,0 0,4 2.09c2.26,0 3.63,-1.3 3.63,-2.91 0,-3.68 -8,-2.1 -8,-6.81 0,-2.22 2.14,-3.79 5.52,-3.79a6.66,6.66 0,0 1,3.76 0.94,5.44 5.44,0 0,0 -0.69,1.68h-0.3a3.11,3.11 0,0 0,-3 -1.88c-1.91,0 -3.28,1 -3.28,2.48 0,3.75 8,2.18 8,6.61 0,2.45 -2.31,4.51 -6.23,4.51A7.24,7.24 0,0 1,380 94.13a4.91,4.91 0,0 0,0.48 -1.78h0.3Z"
    android:fillColor="#fff"/>
</vector>

回答1:


This seems to have been fixed with the latest version of Android Studio (2.0) and Build Tools (23.0.3). I also removed generatedDensities = [] and aaptOptions { additionalParameters "--no-version-vectors" } as well as support and appcompat libraries, relying soley on the design library. I have tested on both Jellybean and Lollipop devices and while the vector preview still looks distorted in Android Studio, it shows up just fine on all physical devices. Seems like this issue was a bug on Google's end.



来源:https://stackoverflow.com/questions/36434492/vector-drawable-distorted

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!