I decided to use svg-files in my project. My choice fell on this library
I convert SVG images to an xml resource using a plugin for AndroidStudio - SVG2VectorDrawable. The output is the following xml:
<?xml version="1.0" encoding="utf-8"?> <vector xmlns:android="http://schemas.android.com/apk/res/android" android:viewportWidth="500" android:viewportHeight="500" android:width="500dp" android:height="500dp"> <group android:name="layer1" android:translateY="-552.36218" android:translateX="0"> <path android:pathData="m 249.61649,554.37094 c -136.86649,0 -247.92681,111.06032 -247.92681,247.92681 0,136.8665 111.06032,247.66695 247.92681,247.66695 136.8665,0 247.66694,-110.80045 247.66694,-247.66695 0,-136.86649 -110.80044,-247.92681 -247.66694,-247.92681 zm -95.11657,98.75492 271.83589,157.4881 c -102.83575,57.01556 -160.15202,89.00467 -271.83589,157.4881 l 0,-314.9762 z" android:name="path3871" android:fillColor="#673AB7" android:fillAlpha="1" android:strokeColor="#00FFFFFF" /> </group> </vector>
In the code I use everything as in the example:
imageView = (ImageView)findViewById(R.id.imageView); imageView.setLayerType(View.LAYER_TYPE_SOFTWARE, null); try { SVG svg = SVG.getFromResource(this, R.drawable.vector_drawable_vector_playup); Drawable drawable = new PictureDrawable(svg.renderToPicture()); imageView.setImageDrawable(drawable); } catch(SVGParseException e) { Log.d("Test","e: "+e.toString()); }
The result of my work is the following Exception :
com.caverock.androidsvg.SVGParseException: SVG parse error: At line 1, column 0: not well-formed (invalid token)
If anyone has encountered a similar problem or simply knows its solution, please answer. I've already read Google and Stack - I haven't found a solution yet.