Android Load image dinamically using WebVIew
Posted: Tue Jan 27, 2015 7:01 pm
if the picture you want to display is in /sdcard/image.png and in your layout you have a WebView called (R.id.)mwebview
As it's HTML, you can resize the image using height="yy" and width="xx"
Code: Select all
WebView mWebview = (WebView) findViewById(R.id.mwebview);
String base = Environment.getExternalStorageDirectory().getAbsolutePath().toString();
String imagePath = "file://" + base + "/image.png";
String html = "<html><head></head><body><img height=\"150\" width=\"190\" src=\"" + imagePath + "\"></body></html>";
mWebview.loadDataWithBaseURL("file:///mnt/sdcard/", html, "text/html","utf-8", "");
As it's HTML, you can resize the image using height="yy" and width="xx"