I am trying to use VectorDrawables in my Android App.
I want to load an xml File from the File System and get an Instance of android.graphics.Drawable
to displa
Actually, yes you can, and I've done it in my own projects.
As mentioned in the previous answer though, you indeed need the compiled version of the XML drawable instead of the one you get from, say, Android Studio. AFAIK, the VectorDrawable API does not yet support loading from raw XML.
To do this, simply place your images temporarily under the res
directory so that they get compiled as normal resources during the build process, then find your generated APK and extract them from there (you'll notice they're no longer text files, but binary files). Now put them again wherever you want under your assets dir and use code similar to this to load them as drawables:
XmlResourceParser parser = context.getAssets()
.openXmlResourceParser("assets/folder/image.xml");
drawable = VectorDrawableCompat.createFromXml(context.getResources(), parser);
Notice the 'assets/' part of the path. That's required, afaik.