Solution: PhoneGap does not support viewport.

Source: Internet
Author: User

Solution: PhoneGap does not support viewport.

When you used phonegap to compile GameBuilder + CanTK a few days ago, the viewport in HTML is invalid. CanTK detects the DPI of the device based on devicePixelRatio and uses viewport to set the correct resolution. If viewport is invalid, CanTK can only run at the lowest resolution. I checked it online and did not find the system information. However, I know that WebView must have corresponding settings to enable viewport. Combined with the information found and the source code of phonegap, finally, the solution is found. Here is a summary:

  • Solution for iOS: add a line of configuration in config. xml of phonegap:

    <preference name="EnableViewportScale" value="true"/>

    (The strange thing is that this method is invalid for the android platform. I have read CordovaWebView. java, and there are no relevant settings in it)
  • Solution 1 of the android platform: Modify CordovaWebView. java:

    Settings. getUserAgentString (); // Add the following two lines of code: settings. setUseWideViewPort (true); settings. setLoadWithOverviewMode (true );
  • Solution 2 of the android platform: direct modification of CordovaWebView. java is a good solution. However, GameBuilder + CanTK supports cloud compilation of phonegap and cannot directly modify CordovaWebView. java. I thought of the phonegap plug-in and found a ViewPortScale plug-in. I found that it could not be compiled, so I wrote a com. tangide. viewport plug-in. If you use cloud compilation provided by GameBuilder + CanTK, this plug-in has been built in. The plug-in source code is here:

    https://github.com/drawapp8/ViewPort

Related Article

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.