Quantcast
Channel: Android point
Viewing all articles
Browse latest Browse all 106

Display image in WebView

$
0
0
If you are so lazy as me! Display image in WebView is a good choice.

Java Code:

package com.image.webview;

import android.os.Bundle;
import android.os.Environment;
import android.app.Activity;
import android.webkit.WebView;

public class MainActivity extends Activity {

WebView webView;
String imagePath = "/sunil.png";

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//setContentView(R.layout.activity_main);

webView = new WebView(this);
setContentView(webView);

String fullUrl = "file://"
+ Environment.getExternalStorageDirectory().getAbsolutePath().toString()
+ "/"
+ imagePath;
webView.loadUrl(fullUrl);
webView.getSettings().setBuiltInZoomControls(true);
webView.getSettings().setUseWideViewPort(true);
webView.getSettings().setLoadWithOverviewMode(true);

}

}

Need To add INTERNET permission.


 Cheers Guys!!

Viewing all articles
Browse latest Browse all 106

Trending Articles