show Image from a URL in WebView - Android android.graphics

Android examples for android.graphics:Image Load Save

Description

show Image from a URL in WebView

Demo Code

import android.content.Context;
import android.webkit.WebView;

public class Main {

  public static void showNetImage(Context mContext, final WebView webview, final String imageLocalUrl, int width,
      int height) {
    final String fileName = "image.png";

    String data = "<HTML><IMG src=\"" + imageLocalUrl + "\"" + "width=" + width + "height=" + height + "/>";
    webview.loadDataWithBaseURL(imageLocalUrl, data, "text/html", "utf-8", null);

    webview.getSettings().setBuiltInZoomControls(true);
    webview.getSettings().setSupportZoom(true);
    webview.setSaveEnabled(true);/*from  w  w  w .j a  v a2s .c  o  m*/

  }

}

Related Tutorials