问题描述
在应用程序中有一个 webview 可以查看带有小插图广告的网页,但该广告未在 webview 中显示,而是在其他媒体中显示,可能是什么原因?是否有任何政策阻止它出现?
解决方法
发现添加这些行会在网页中启用 Vignette
webView.getSettings().setJavaScriptEnabled(true);
//Zoom
webView.getSettings().setBuiltInZoomControls(true);
webView.getSettings().setDisplayZoomControls(false);
//Cache and storage
webView.getSettings().setAppCacheEnabled(true);
webView.getSettings().setDatabaseEnabled(true);
webView.getSettings().setDomStorageEnabled(true);
webView.getSettings().setUseWideViewPort(true);
webView.getSettings().setLoadWithOverviewMode(true);
webView.getSettings().setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);
//optional settings
webView.getSettings().setAppCachePath(getApplicationContext().getCacheDir().getAbsolutePath());
webView.getSettings().setAllowFileAccess(true);
webView.getSettings().setAppCacheEnabled(true);
//Others
webView.setFocusable(true);
webView.setFocusableInTouchMode(true);
webView.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY);
webView.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);//the best for games