1

I'm using a modified version of this slider lib that uses fresco lib instead of Picasso.

I'm getting the SVG from a RESTful server as a String. And the loading process works somewhat like:

protected void bindEventAndShow(final View v, SimpleDraweeView targetImageView){

    // ...

    // This URL is provided elsewhere, just putting it here for readability.
    String url = "http://foo.bar/resource";

    ControllerListener controllerListener = new BaseControllerListener<ImageInfo>() {
        // onFinalImageSet(), onIntermediateImageSet(), onFailure methods here
    }

    DraweeController controller = Fresco.newDraweeControllerBuilder().setControllerListener(controllerListener)
                        .setImageRequest(ImageRequest.fromUri(url))
                        .build();

    // ...

    targetImageView.setHierarchy(hierarchy);
    targetImageView.setController(controller);
}

When I provide a URL with PNG or JPEG, it works wonders. But if the URL gives back a SVG, it doesn't work at all.

I want to know if it's possible to load a SVG String/File directly into Fresco. If it's not possible directly, how can it be done?

P.S.: I could try to transform it to PNG or JPG, save it on disk and only then load it on the slider, but I'm not sure if it's the best approach.

Mauker
  • 11,237
  • 7
  • 58
  • 76

2 Answers2

3

Acording with github repository, they dont support svg.

https://github.com/facebook/fresco/issues/1008

https://github.com/facebook/fresco/issues/329

You should use other library like glide.

https://github.com/bumptech/glide

An example:

https://github.com/bumptech/glide/tree/master/samples/svg/src/main/java/com/bumptech/glide/samples/svg

  • Marking as accepted, as Fresco doesn't really support SVG. Using Glide seems to be the best approach here. – Mauker Mar 01 '16 at 13:05
1

You still can make it work use Fresco library with custom SVG decoder.

Have a look this example here.

Arsenius
  • 4,972
  • 4
  • 26
  • 39