android - SVG as image view in different location -
i have read questions here svg in android , comparing each answer , found out answers similar in each other. question is, possible use svg format in imageview
in different locations?many answers in common location
// parse svg resource "raw" resource folder svg svg = svgparser.getsvgfromresource(getresources(), r.raw.android);
what want notgetresources(), r.raw.android
. wanted locate in specific folder
string mpath = environment.getexternalstoragedirectory().tostring() + "/juniefolder/junie_screenshot" + + ".png";
i wanted change change images inimageview
dynamically. possible achieve this?
`
below code view svg format
string path = environment.getexternalstoragedirectory().tostring() + "/juniefolder/junie_screenshot" + + ".svg"; file file = new file(path); uri uri = uri.fromfile(file); svgimageview.setimageuri(uri); imageview imageview = new imageview(this); imageview.setbackgroundcolor(color.white); svg svg = svgparser.getsvgfromresource(getresources(),r.raw.android); imageview.setimagedrawable(svg.createpicturedrawable()); imageview.setlayertype(view.layer_type_software, null); //setcontentview(imageview); svgimageview.setimageuri(uri)
i think way select image folder
svg svg = svgparser.getsvgfromstring(path);
not
svg svg = svgparser.getsvgfromresource(getresources(),r.raw.android);
you should able make work using androidsvg library. svgimageview
class has method setimageuri
, this:
string path = environment.getexternalstoragedirectory().tostring() + "/juniefolder/junie_screenshot" + + ".svg"; file file = new file(path); uri uri = uri.fromfile(file); svgimageview.setimageuri(uri);
you can use setimageasset
, setimageresource
methods load svgs assets or resources.
Comments
Post a Comment