[英]Blurry svg image in Android
I added a user svg image from this website. 我在这个网站上添加了一个用户svg图像。 The image should be sharp, but when i use it in my app as a default user image it is very blurry. 图像应该很清晰,但当我在我的应用程序中使用它作为默认用户图像时,它非常模糊。
<!-- Thumbnail Image -->
<com.android.volley.toolbox.NetworkImageView
android:id="@+id/thumbnail"
android:background="@drawable/ic_icon_user"
android:layout_width="80dp"
android:layout_height="80dp"
android:layout_alignParentLeft="true"
android:layout_marginRight="8dp" />
Also how would I edit a svg image color in android. 另外我如何在android中编辑svg图像颜色。 I tried adding a custom color, but it didn't work. 我尝试添加自定义颜色,但它没有用。
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportHeight="24"
android:viewportWidth="24">
<path
android:fillColor="@color/ColorRed"
android:pathData="M12,4A4,4 0 0,1 16,8A4,4 0 0,1 12,12A4,4 0 0,1 8,8A4,4 0 0,1 12,4M12,14C16.42,14 20,15.79 20,18V20H4V18C4,15.79 7.58,14 12,14Z" />
</vector>
Adding this to app build.gradle
helped me to fix the problem with blurry svg images: 将此添加到app build.gradle
帮助我解决模糊的svg图像的问题:
android {
defaultConfig {
vectorDrawables.useSupportLibrary = true
}
}
In Android Manifest.xml, set for your activity (blur doesn't work when hardware acceleration is true) 在Android Manifest.xml中,为您的活动设置(当硬件加速为真时,模糊不起作用)
android:hardwareAccelerated="false"
You can disable hardware acceleration on the VIEW level: 您可以在VIEW级别禁用硬件加速:
myView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
Well similar problem happened to me. 类似的问题发生在我身上。 I was using 我在用
app:srcCompat="@drawable/your_image".
Turns out this was causing the problem. 事实证明这导致了这个问题。 You need to change it to this: 您需要将其更改为:
android:src="@drawable/your_image".
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.