我正在編寫Phonegap(3.2)應用程序,我使用HTML5畫布,使其全屏,並且整個應用程序UI均位於此畫布上。PhoneGap App上的屏幕分辨率
使用三星Galaxy S4(Android 4.3)測試應用程序,該應用程序的屏幕分辨率只有360X640而不是像我想要的1080X1920。
爲了使應用程序使用最大可能的屏幕分辨率,需要做些什麼?
我已經添加了屏幕截圖 1)//看起來不錯,但糟糕的分辨率
WINDOWWIDTH = window.innerWidth; windowHeight = window.innerHeight;
2)//注意到屏幕的一小部分,其餘的是白
WINDOWWIDTH = window.outerWidth; windowHeight = window.outerHeight;
3)//只有圖像的一小部分是可見的,就好像圖像是1080X1920一樣,但屏幕對它來說太小了。
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>
感謝。
不錯。我完全忘了這個:) – K3N