Several methods to solve phonegap not supporting viewport

Source: Internet
Author: User

A few days ago, when compiling GAMEBUILDER+CANTK with PhoneGap, the viewport in HTML was found to be invalid. The CANTK detects the DPI of the device according to the Devicepixelratio and then sets the correct resolution with viewport. If viewport is not valid, CANTK can only run at the lowest resolution. Check on the Internet, also did not find the system information, but I know webview must have the corresponding settings to enable viewport, combined with the information found and PhoneGap source, finally found a solution, here to summarize:

    Workaround for the
    • iOS platform: Add a single line of configuration in config. phonegap:

      <preference name= "Enableviewportscale" value= " True "/>

      (strange that this method is not valid for Android platform, I looked at Cordovawebview.java, there is no related settings)
    • Android Workaround for Platform One: Modify Cordovawebview.java:

       settings.getuseragentstring     (); //add the following two lines of code:  settings.setusewideviewport (true    );
       Settings.setloadwithoverviewmode (true );  
    • Workaround for Android platform two: it's a good idea to modify Cordovawebview.java directly, but GAMEBUILDER+CANTK supports PhoneGap cloud compilation, There is no way to modify Cordovawebview.java directly. I think of the phonegap plug-in, found a Viewportscale plug-in, found that the basic compiler can not, so I wrote a com.tangide.viewport plug-in, if the use of GAMEBUILDER+CANTK provided by the cloud compilation, This plugin has been built in. Plugin source code is here:

      https: // Github.com /drawapp8/viewport  

To resolve several ways that PhoneGap does not support viewport

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.