android:load svg file from web and show it on image view

Update: For newer version please checkout the Glide Samples (https://github.com/bumptech/glide/tree/master/samples/svg) – You can use Glide (https://github.com/bumptech/glide/tree/v3.6.0) and AndroidSVG (https://bitbucket.org/paullebeau/androidsvg). There is also a sample from Glide: https://github.com/bumptech/glide/tree/v3.6.0/samples/svg/src/main/java/com/bumptech/svgsample/app Setup GenericRequestBuilder requestBuilder = Glide.with(mActivity) .using(Glide.buildStreamModelLoader(Uri.class, mActivity), InputStream.class) .from(Uri.class) .as(SVG.class) .transcode(new SvgDrawableTranscoder(), PictureDrawable.class) .sourceEncoder(new StreamEncoder()) .cacheDecoder(new FileToStreamDecoder<SVG>(new SvgDecoder())) .decoder(new SvgDecoder()) .placeholder(R.drawable.ic_facebook) .error(R.drawable.ic_web) .animate(android.R.anim.fade_in) .listener(new SvgSoftwareLayerSetter<Uri>()); Use RequestBuilder with … Read more

Android Picasso library, How to add authentication headers?

Since Picasso 2.5.0 OkHttpDownloader class has been changed, assuming you are using OkHttp3 (and so picasso2-okhttp3-downloader), so you have to do something like this: OkHttpClient client = new OkHttpClient.Builder() .addInterceptor(new Interceptor() { @Override public Response intercept(Chain chain) throws IOException { Request newRequest = chain.request().newBuilder() .addHeader(“X-TOKEN”, “VAL”) .build(); return chain.proceed(newRequest); } }) .build(); Picasso picasso = … Read more

Android Picasso – Placeholder and Error image styling

You can use a placeholder image by using the *.placeholder(R.drawable.image_name)* in your Picasso call like: Picasso.with(context) .load(imageUrl) .placeholder(R.drawable.image_name) If you want to use a progress bar instead of a placeholder image you can create a callback inside the .into function. Do something similar to the following: in your view: //create the progressBar here and set … Read more

Why use Android Picasso library to download images?

Just for the record for anyone new to Android or perhaps moving to Android from iOS ………. Until something drastically changes, you absolutely have to use Picasso. Not a joke. Honestly, it’s that simple. The advantages are unbelievable. It’s this easy to use: Picasso. with(State.mainContext). load(parseImageFile.getUrl()). into(null); You very simply: must do caching, and threading, … Read more

tech