& Lt; Android & gt; simple WebView announcement adaptation in the game, androidwebview

Source: Internet
Author: User

<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 );}});






Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.