Android webview settings and more tutorials aide ide


Sample useful android webview codes to improve your webview performance and for having more controll.

Webview  enable zoom:
webView.getSettings().setBuiltInZoomControls(true);

Allowed image to load inside webview  [Change into "true" to enable and false for disable]
webView.getSettings().setLoadsImagesAutomatically(true);

Enable javascript run inside in your webview
webView.getSettings().setJavaScriptEnabled(true);

Enable Domstorage and Cache:
webView.getSettings().setDomStorageEnabled(true);
webView.getSettings().setAppCacheEnabled(true);

Set useragent of webview:
webView.getSettings().setUserAgentString("Mozilla/5.0 (Linux; Android 8.0.0;) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.162 Mobile Safari/537.36");

Webview  refer url:
Map<String, String> extra = new HashMap<String, String>();
extra.put("Referer", "https://www.google.com/");
webView.loadUrl("https://sample.com", extra);

Webview set client:
wxx.setWebViewClient(new WebViewClient() {
@Override
public void onPageStarted(WebView view, String url, Bitmap favicon)
{
super.onPageStarted(view, url, favicon);
}
@Override
public void onPageFinished(WebView view, String url)
{
super.onPageFinished(view, url); 


}

@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return true;
}
});

Webview transparent background:
webView.setBackgroundColor(Color.TRANSPARENT);

for more webview setting please visit this link  http://developer.android.com/reference/android/webkit/WebView.html


Comments

Popular posts from this blog

Implement in-app purchase in aide ide

Implement google admob interstitial ads in aide ide

Implement a-ads on blogger or website

Android play .gif file on imageview in aide ide

Aide ide tutorial - Add line graph


Malitanyo Developer blog & tutorial 2020
Refund Policy    Facebook Page    Google Play

Blogger.com