4

我有许多使用可绘制矢量作为源的图像视图。对于它们中的大多数来说,它是材质图标,但是当我导入更复杂的矢量时,它在 Lollipop 设备上显示为失真,但在 Jellybean 设备上却很好。这应该说 SYSTEMS 但显然有问题。

向量

布局:

<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 构建文件:

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

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

矢量可绘制:

<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>
4

1 回答 1

1

这似乎已在最新版本的 Android Studio (2.0) 和 Build Tools (23.0.3) 中得到修复。我还删除了generatedDensities = []以及aaptOptions { additionalParameters "--no-version-vectors" }支持和 appcompat 库,仅依赖于设计库。我已经在 J​​ellybean 和 Lollipop 设备上进行了测试,虽然矢量预览在 Android Studio 中看起来仍然失真,但它在所有物理设备上都显示得很好。似乎这个问题是谷歌端的一个错误。

于 2016-04-12T19:26:31.713 回答