问题描述
我在写一个Phonegap(3.2)应用程序,我使用一个HTML5画布,使其全屏,整个应用程序UI都在这个画布上。
I'm writing a Phonegap (3.2) app, I take a HTML5 canvas, make it full screen and the whole app UI is on this canvas.
一个三星Galaxy S4(Android 4.3)来测试应用程序,应用程序的屏幕分辨率只有360X640,而不是1080X1920像我想要的。
Using a Samsung Galaxy S4 (Android 4.3) to test the app, the screen resolution of the app is only 360X640 and not 1080X1920 like I want it to be.
需要什么为了使应用程序使用尽可能最大的屏幕分辨率?
What is needed to be done in-order to make the app use the maximum possible screen resolution ?
我添加了屏幕截图
1)//看起来确定,但不好
I've added screen shots1) // Looks OK but bad resolution
windowWidth = window.innerWidth;
windowHeight = window.innerHeight;
windowWidth = window.innerWidth;windowHeight = window.innerHeight;
2 )//占用屏幕的一小部分,其余部分是白色。
2) // Takes small part of the screen, rest is white
windowWidth = window.outerWidth;
windowHeight = window.outerHeight;
windowWidth = window.outerWidth;windowHeight = window.outerHeight;
3 )//只有图片的一小部分是可见的,如果图片是1080X1920,但是屏幕太小了。
3) // Only a small part of the picture is visible, as if the image is at 1080X1920 but the screen is 'too small' for it.
windowWidth = screen。宽度;
windowHeight = screen.height;
windowWidth = screen.width;windowHeight = screen.height;
和这里是完整的代码:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>PhoneGapTesting</title>
<script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript" charset="utf-8" src="cordova.js"></script>
<!-- -->
<script type="text/javascript">
var windowWidth;
var windowHeight;
var canvasMain;
var contextMain;
var backgroundImage;
$(document).ready(function() {
windowWidth = window.innerWidth;
windowHeight = window.innerHeight;
//windowWidth = window.outerWidth; // Only 'window.innerWidth' + 'window.innerHeight' look OK but not max resolution
//windowHeight = window.outerHeight;
//windowWidth = screen.width;
//windowHeight = screen.height;
canvasMain = document.getElementById("canvasSignatureMain");
canvasMain.width = windowWidth;
canvasMain.height = windowHeight;
contextMain = canvasMain.getContext("2d");
backgroundImage = new Image();
backgroundImage.src = 'img/landscape_7.jpg';
backgroundImage.onload = function() {
contextMain.drawImage(backgroundImage, 0, 0, backgroundImage.width, backgroundImage.height, 0, 0, canvasMain.width, canvasMain.height);
};
$("#canvasSignatureMain").fadeIn(0);
})
</script>
</head>
<body scroll="no" style="overflow: hidden">
<center>
<div id="deleteThisDivButNotItsContent">
<canvas id="canvasSignatureMain" style="border:1px solid #000000; position:absolute; top:0;left:0;"></canvas><br>
</div>
</center>
</body>
</html>
谢谢。
推荐答案
解决方案与解决方案和触摸事件问题(与肯的帖子):
A solution that is working with both resolution and touch event issue (that came with Ken's post):
<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height, target-densitydpi=device-dpi" />
head>
感谢Ken尝试帮助bro:))
Thanks Ken for trying to help bro :))
这篇关于PhoneGap应用程序上的屏幕分辨率的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!