0

I am new to mobile development. I am using Cordova with Visual Studio 2013 Update 4. I just added some text in the default index.html of BlankCordovaApp1. I created the apk and installed it on my android phone. But when I run the app on my phone, I cannot zoom by pinching. I read some advice about Java code for android (but I work in Visual Studio, no java).

1)I read and tried the following but to no avail:

<meta name='viewport' content='initial-scale=1.0,minimum-scale=1.0, maximum-scale=10.0;user-scalable=yes' />

2)This solution Cordova : How to enable viewport zoom says "put following in the onCreate method of your main Android Java File inside src/com/packagename directory", but there is no "src" folder in my Visual Studio folders.

3)I also tried to put this in config.xml, but it didn't help.

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

Can you help me? Thanks

Community
  • 1
  • 1
GeoDev
  • 1
  • 4
  • Can you please provide the device specifics on which you are trying the pinch gesture? I believe this works with a standard native app for Android right? – Subhag Oak May 07 '15 at 19:45
  • I don't know about native apps. But I did it using the inappbrowser plugin. – GeoDev May 08 '15 at 07:09

2 Answers2

0

I'm also new in Cordova, I use it for 3 months only, I guess you have this question because the font-size is "sometimes" too small to be seen in SOME android phones. I found that the font-size and screen size are different for different phones so you need to "calculate" the screen size in order to have better display.

For example, I use the javascript and css to set the windowHeight, windowWidt and fontSize of the main DIV in order to have same looking in different phones.

e.g.

<html>
<body>
<div id="divTest"> Hello </div>
</body>


<script>
if (typeof (window.innerWidth) == 'number') {
        windowHeight = window.innerHeight;
        windowWidth = window.innerWidth;
    } else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
        windowHeight = document.documentElement.clientHeight;
        windowWidth = document.documentElement.clientWidth;

    } else if (document.body && (document.body.clientWidth || document.body.clientHeight)) {
        windowHeight = document.body.clientHeight;
        windowWidth = document.body.clientWidth;
    }


// try divided by other values instead of 28 to find the differences.
FontHeight = Math.round(windowHeight / 28);

divTest.height = windowHeight + "px";
divTest.width = windowWidth + "px";
divTest.fontSize = FontHeight + "px";
</script>
</html>

using the above html, the size of "Hello" should be the same "ratio" for different android phones.

Kenneth Li
  • 1,632
  • 1
  • 14
  • 19
0

I did it using the inappbrowser plugin.

GeoDev
  • 1
  • 4