PDA

View Full Version : How to get Screen / Device width and Height



jackson7
29 Apr 2012, 5:17 PM
Hello everyone,

I am developing an App using Sencha Touch 2. I am trying to find out the device/screen width and height, but I can't seem to figure it out. I have tried using:



Ext.Viewport.getWidth();


which returns 100%. However, I would need to know the width/height in pixels. I need to embed a video, and I need to maintain aspect ratio for different device resolutions.

There's the traditional Javascript approach:



var width = (window.innerWidth > 0) ? window.innerWidth : screen.width;


which seems to work fine, but I would like to know the proper way to do it in Sencha Touch 2.

Any Help would be appreciated.


Thanks,

mitchellsimoens
1 May 2012, 5:30 AM
There is nothing wrong with getting the size off the window.

jackson7
3 May 2012, 8:54 AM
There is nothing wrong with getting the size off the window.

Thanks!