useViewport Method

This method tells intel.xdk to size down an application for a smaller device.

intel.xdk.display.useViewport(widthPortrait,widthLandscape);

Description:

This method tells intel.xdk to size down an application for a smaller device. Use this method in your application’s intel.xdk.device.ready event to size a larger application down for use on a smaller device than it was originally designed for.

This method expects two values, the first is the width the application is designed for in portrait orientation, and the second is the width the application is designed for in landscape orientation.

Unfortunately, several newer Android devices have changed their version of the Android operating system to a point that this command does not work. At this point, the list of devices that are known to ignore this functionality include:
HTC EVO 4G
HTC Legend
HTC Evolution 4G
HTC Thunderbolt
HTC Sensation

Available Platforms:

Parameters:

  • widthPortrait: The width to set the device to display at in pixels when the device is in portrait orientation.
  • widthLandscape: The width to set the device to display at in pixels when the device is in landscape orientation.

Example:


//use intel.xdk viewport to allow this iPad-designed application to size down to an iPhone //or an Android handset device with a resolution lower than 1024x768.
var iPortraitWidth=768;
var iLandscapeWidth=1024;
intel.xdk.display.useViewport(iPortraitWidth,iLandscapeWidth);
            
Para obtener más información sobre las optimizaciones del compilador, consulte el aviso sobre la optimización.