Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Blurry svg image in Android

I added a user svg image from this website. 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. 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>
like image 487
Banana Avatar asked Sep 13 '16 09:09

Banana


People also ask

Why does my SVG look blurry?

The issue of blurriness arises when you upload an image that has the exact pixel dimensions of the space you are targeting. The exact reason has to do with the resolution of modern screens.

How do I make SVG not blurry?

It seems the solution is to set the desired size of your SVG in your editing program and then make certain all of your pixels align to the grid. This will still allow your SVG to scale up but will also allow it to render at the smaller size.

Is SVG compatible with Android?

Android Studio includes a tool called Vector Asset Studio that helps you add material icons and import Scalable Vector Graphic (SVG) and Adobe Photoshop Document (PSD) files into your project as vector drawable resources.


1 Answers

Adding this to app build.gradle helped me to fix the problem with blurry svg images:

android {
  defaultConfig {
    vectorDrawables.useSupportLibrary = true
  }
}
like image 90
Olga Liakhovich Avatar answered Sep 21 '22 00:09

Olga Liakhovich