package com.example.androidwebviewphoto; 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 = "/tmp/testphoto.jpg"; @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); } }
Jul 12, 2012
Display image in WebView
If you are so lazy as me! Display image in WebView is a good choice.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment