VectorDrawable 以像素显示
VectorDrawable is shown with pixels
我用 VectorDrawable 创建了 ImageView。在 android 模拟器中一切正常,但在我的 phone 中图像像素化。
<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" />
如果您的设备版本 API 低于 21,则必须将此行添加到 Gradle 中的 defaultConfig:
android {
defaultConfig {
vectorDrawables.useSupportLibrary = true
}
}
而且你必须使用 app:srcCompat="@drawable/ic_circle"
而不是 android:src="@drawable/ic_circle"
。
改变
android:src="@drawable/ic_circle"
至
app:srcCompat="@drawable/ic_circle"
我用 VectorDrawable 创建了 ImageView。在 android 模拟器中一切正常,但在我的 phone 中图像像素化。
<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" />
如果您的设备版本 API 低于 21,则必须将此行添加到 Gradle 中的 defaultConfig:
android {
defaultConfig {
vectorDrawables.useSupportLibrary = true
}
}
而且你必须使用 app:srcCompat="@drawable/ic_circle"
而不是 android:src="@drawable/ic_circle"
。
改变
android:src="@drawable/ic_circle"
至
app:srcCompat="@drawable/ic_circle"