【问题标题】:VectorDrawable is shown with pixelsVectorDrawable 以像素显示
【发布时间】:2019-08-28 09:27:03
【问题描述】:

我用 VectorDrawable 创建了 ImageView。在 android 模拟器中一切正常,但在我的手机中,图像是像素化的。

<ImageView
    android:id="@+id/image_circle_hello"
    android:layout_width="50dp"
    android:layout_height="50dp"
    android:contentDescription="@string/hello"
    android:src="@drawable/ic_circle"
    android:layout_gravity="center_horizontal" />

【问题讨论】:

标签: android android-vectordrawable


【解决方案1】:

如果您的设备版本 API 小于 21,则必须将此行添加到 Gradle 中的 defaultConfig:

android {
    defaultConfig {
        vectorDrawables.useSupportLibrary = true
    }
}

您还必须使用app:srcCompat="@drawable/ic_circle" 而不是android:src="@drawable/ic_circle"

【讨论】:

    【解决方案2】:

    改变

    android:src="@drawable/ic_circle"
    

    app:srcCompat="@drawable/ic_circle"
    

    【讨论】:

      猜你喜欢
      • 2016-09-13
      • 1970-01-01
      • 1970-01-01
      • 2019-12-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多