Phonegap android gets actual screen size

I know there are many questions similar to my headline, but I could not find the answer I want.

In my application, I use window.innerWidthand window.innerHeightto get the screen size, but these two values ​​return a different size. For example, when I run my application in Note 3, I get 360x615, whereas it should be 1080x1920.

The following code in Java gives me what I want:

    Display display = getWindowManager().getDefaultDisplay();
    Point size = new Point();
    display.getSize(size);
    int width = size.x;
    int height = size.y;

So, is there a way in Phonegap to get the same screen size as Java?

Update: when I test the same code on note 2 with Beans jelly, I get the correct size 720x1230

+4
source share
2 answers

,

var physicalScreenWidth = window.screen.width * window.devicePixelRatio;
var physicalScreenHeight = window.screen.height * window.devicePixelRatio;
+4

, CSS-? .

, , screen.width screen.height. CSS, window.innerWidth window.innerHeight.

meta viewport Android, Samsung Galaxy.

+3

All Articles