<Android> simple WebView announcement adaptation in the game, androidwebview
The company is developing a cocos2dx game and needs a simple announcement. On the one hand, the company does not have the technical strength reserve of html5, and on the other hand, the company has no experience in adapting to the mobile phone webpage, in the end, such a hard job was lost on the WebView.
<Pre name = "code" class = "java">/*** <meta name = "viewport" content = "width = 640"/> html does not use * content =" width = device-width "webView custom control, the size is not the screen * screen size */webView. setScrollBarStyle (WebView. SCROLLBARS_OUTSIDE_OVERLAY); webView. setHorizontalScrollbarOverlay (true); webView. getSettings (). setJavaScriptEnabled (true);/** the browser's built-in scaling does not allow you to return the initial set scale (setInitialScale (int scale )), * The scaling ratio must be a fixed difference. Currently, zooming is not supported */webView. getSet Hide (). setsuppzoom zoom (false);/** LayoutAlgorithm. SINGLE_COLUMN: Place all content in the same width column of the WebView component. * This is mandatory and will squeeze and deform complex webpages */webView. getSettings (). setLayoutAlgorithm (LayoutAlgorithm. SINGLE_COLUMN); float sScale = fWidth/webWidth * 100; webView. setInitialScale (int) sScale);/*** common WebView listeners */webView. setWebViewClient (new WebViewClient () {public boolean shouldOverrideUrlLoading (WebView view, String url) {// return true ;}}); webView. setDownloadListener (new DownloadListener () {@ Overridepublic void onDownloadStart (String url, String userAgent, String contentDisposition, String mimetype, long contentLength) {//}); webView. setWebChromeClient (new WebChromeClient () {@ Overridepublic void onProgressChanged (WebView view, int newProgress) {if (newProgress = 100) {//} super. onProgressChanged (view, newProgress );}});