找到你要的答案

Q:Zoom in Cordova application in Visual Studio

Q:放大科尔多瓦在Visual Studio中的应用

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

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)我读了,试了以下,但无济于事:

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

2)本方案科多瓦:如何使视口缩放说“放在onCreate方法你的主要Android java文件里面SRC / COM /软件目录”,但我的Visual Studio文件夹没有“src”文件夹。

3)我也试图把这个xml,但它并没有帮助。

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

Can you help me? Thanks

answer1: 回答1:

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.

我也在科尔多瓦,我用它只有3个月,我猜你有这个问题,因为字体大小是“有时”太小,在一些安卓手机看到。我发现字体大小和屏幕尺寸对于不同的手机是不同的,所以你需要“计算”屏幕的大小,以便有更好的显示。

例如,我使用JavaScript和CSS来设置windowheight windowwidt和字体,以主要的div有相同的期待在不同的手机。

例如

<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>

使用上面的HTML,大小的“你好”,应针对不同的Android手机相同的“比”。

answer2: 回答2:

I did it using the inappbrowser plugin.

我没有使用inappbrowser插件。

visual-studio  cordova  zoom  visual-studio-cordova