I am displaying a fairly large image in a webview so that the pinch-to-zoom functions and other conveniences for viewing are already available.
It displays correctly the
WebViewActivity.java
public class WebViewActivity extends AppCompatActivity {
private WebView mWebView;
private RelativeLayout mWebViewParent;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_web_view);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
mWebViewParent = (RelativeLayout) findViewById(R.id.layoutWebViewParent);
mWebView = (WebView)findViewById(R.id.webView);
// Other stuff
}
@Override
protected void onDestroy() {
super.onDestroy();
destroyWebView();
}
private void destroyWebView() {
mWebViewParent.removeAllViews();
if(mWebView != null) {
mWebView.clearHistory();
mWebView.clearCache(true);
mWebView.loadUrl("about:blank");
mWebView.freeMemory();
mWebView.pauseTimers();
mWebView = null;
}
android.os.Process.killProcess(android.os.Process.myPid());
}
}
activity_web_view.xml
AndroidManifest.xml
Hope this will help you.