title: How to use SVG image in ImageView
body: <p>Good Day, I have a <code>SVG</code> image. How can I add it to <code>ImageView</code> background ?</p>
  
  <p>I tried to use <a href="https://github.com/BigBadaboom/androidsvg" rel="noreferrer">this library</a> But I have problem:</p>
  
  <pre><code>01-25 12:19:02.669 27719-27719/com.dvor.androidapp E/AndroidRuntime: FATAL EXCEPTION: main
      android.view.InflateException: Binary XML file line #70: Error inflating class com.caverock.androidsvg.SVGImageView
      at android.view.LayoutInflater.createView(LayoutInflater.java:626)
      at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:702)
      at android.view.LayoutInflater.rInflate(LayoutInflater.java:761)
      at android.view.LayoutInflater.rInflate(LayoutInflater.java:769)
      at android.view.LayoutInflater.rInflate(LayoutInflater.java:769)
      at android.view.LayoutInflater.rInflate(LayoutInflater.java:769)
      at android.view.LayoutInflater.rInflate(LayoutInflater.java:769)
      at android.view.LayoutInflater.rInflate(LayoutInflater.java:769)
      at android.view.LayoutInflater.rInflate(LayoutInflater.java:769)
      at android.view.LayoutInflater.inflate(LayoutInflater.java:498)
      at android.view.LayoutInflater.inflate(LayoutInflater.java:398)
      at com.dvor.mobileapp.checkout.ShoppingCart.onCreateView(ShoppingCart.java:411)
      at android.support.v4.app.Fragment.performCreateView(Fragment.java:1786)
      at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:953)
      at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1136)
     at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:739)
     at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1499)
     at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:456)
     at android.os.Handler.handleCallback(Handler.java:730)
     at android.os.Handler.dispatchMessage(Handler.java:92)
     at android.os.Looper.loop(Looper.java:176)
     at android.app.ActivityThread.main(ActivityThread.java:5419)
     at java.lang.reflect.Method.invokeNative(Native Method)
     at java.lang.reflect.Method.invoke(Method.java:525)
     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1046)
     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:862)
     at dalvik.system.NativeStart.main(Native Method)
                                                                            Caused by: java.lang.reflect.InvocationTargetException
     at java.lang.reflect.Constructor.constructNative(Native Method)
     at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
     at android.view.LayoutInflater.createView(LayoutInflater.java:600)
     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:702) 
     at android.view.LayoutInflater.rInflate(LayoutInflater.java:761) 
     at android.view.LayoutInflater.rInflate(LayoutInflater.java:769) 
     at android.view.LayoutInflater.rInflate(LayoutInflater.java:769) 
     at android.view.LayoutInflater.rInflate(LayoutInflater.java:769) 
     at android.view.LayoutInflater.rInflate(LayoutInflater.java:769) 
     at android.view.LayoutInflater.rInflate(LayoutInflater.java:769) 
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:769) 
    at android.view.LayoutInflater.inflate(LayoutInflater.java:498) 
    at android.view.LayoutInflater.inflate(LayoutInflater.java:398) 
    at com.dvor.mobileapp.checkout.ShoppingCart.onCreateView(ShoppingCart.java:411) 
    at android.support.v4.app.Fragment.performCreateView(Fragment.java:1786) 
    at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:953) 
    at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1136) 
   at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:739) 
   at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1499) 
    at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:456) 
    at android.os.Handler.handleCallback(Handler.java:730) 
    at android.os.Handler.dispatchMessage(Handler.java:92) 
    at android.os.Looper.loop(Looper.java:176) 
    at android.app.ActivityThread.main(ActivityThread.java:5419) 
    at java.lang.reflect.Method.invokeNative(Native Method) 
    at java.lang.reflect.Method.invoke(Method.java:525) 
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1046) 
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:862) 
    at dalvik.system.NativeStart.main(Native Method) 
    Caused by: java.lang.NoClassDefFoundError: com.caverock.androidsvg.R$styleable
    at com.caverock.androidsvg.SVGImageView.init(SVGImageView.java:80)
    at com.caverock.androidsvg.SVGImageView.&lt;init&gt;(SVGImageView.java:66)
    at java.lang.reflect.Constructor.constructNative(Native Method) 
    at java.lang.reflect.Constructor.newInstance(Constructor.java:417) 
    at android.view.LayoutInflater.createView(LayoutInflater.java:600) 
    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:702) 
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:761) 
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:769) 
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:769) 
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:769) 
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:769) 
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:769) 
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:769) 
    at android.view.LayoutInflater.inflate(LayoutInflater.java:498) 
    at android.view.LayoutInflater.inflate(LayoutInflater.java:398) 
    at com.dvor.mobileapp.checkout.ShoppingCart.onCreateView(ShoppingCart.java:411) 
    at android.support.v4.app.Fragment.performCreateView(Fragment.java:1786) 
    at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:953) 
    at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1136) 
   at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:739) 
    at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1499) 
     at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:456) 
     at android.os.Handler.handleCallback(Handler.java:730) 
     at android.os.Handler.dispatchMessage(Handler.java:92) 
     at android.os.Looper.loop(Looper.java:176) 
     at android.app.ActivityThread.main(ActivityThread.java:5419) 
     at java.lang.reflect.Method.invokeNative(Native Method) 
     at java.lang.reflect.Method.invoke(Method.java:525) 
     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1046) 
     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:862) 
     at dalvik.system.NativeStart.main(Native Method)
  </code></pre>
  
  <p> </p>
  
  <p><strong>What I did ?</strong></p>
  
  <p>Firstly, I added <code>dependency</code> to <code>gradle</code>:</p>
  
  <pre><code>compile 'com.caverock:androidsvg:1.2.1'
  </code></pre>
  
  <p>Secondly, I changed <code>ImageView</code> to <code>com.caverock.androidsvg.SVGImageView</code></p>
  
  <pre><code> &lt;com.caverock.androidsvg.SVGImageView
           android:id="@+id/recentlyViewed_imgView"
           android:layout_width="100dp"
           android:layout_height="100dp"
           svgimageview:svg="clock.svg"
           /&gt;
  </code></pre>
  
  <p>After that I added <code>xmls:svgimageview</code> to root layout:</p>
  
  <pre><code>&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:svgimageview="http://schemas.android.com/apk/res-auto"
      android:id="@+id/rowItem"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:background="#272727"
      android:clickable="true"
      android:orientation="vertical"&gt;
  </code></pre>
  
  <p>This <code>clock.svg</code> is in the <code>assets</code> folder.</p>