# Titanium.Platform.DisplayCaps

The Display Caps object returned by the displayCaps property.

Availability
0.8
0.8
9.2.0

# Overview

On iPhone and iPod devices with retina display, the density property is high and the dpi property is 320. For other iPhone and iPod devices, density is medium and dpi is 160.

On iPad devices with retina display, the density property is high and the dpi property is 260. For other iPad devices, density is medium and dpi is 130.

Note that Xcode versions prior to 4.3.1 do not have the correct tools to detect the iPad 3 retina display. Apps must be built with Xcode 4.3.1 or later to detect iPad 3 retina display.

Note that the displayCaps property begins with a lowercase letter, which differentiates it from the DisplayCaps object that it returns. Refer to the example to understand how it should be called.

# Examples

# System Display Information

Output the display properties to the system log.

Ti.API.info('Ti.Platform.displayCaps.density: ' + Ti.Platform.displayCaps.density);
Ti.API.info('Ti.Platform.displayCaps.dpi: ' + Ti.Platform.displayCaps.dpi);
Ti.API.info('Ti.Platform.displayCaps.platformHeight: ' + Ti.Platform.displayCaps.platformHeight);
Ti.API.info('Ti.Platform.displayCaps.platformWidth: ' + Ti.Platform.displayCaps.platformWidth);
if((Ti.Platform.osname === 'iphone')||(Ti.Platform.osname === 'ipad')||(Ti.Platform.osname === 'android')){
  Ti.API.info('Ti.Platform.displayCaps.logicalDensityFactor: ' + Ti.Platform.displayCaps.logicalDensityFactor);
}
if(Ti.Platform.osname === 'android'){
  Ti.API.info('Ti.Platform.displayCaps.xdpi: ' + Ti.Platform.displayCaps.xdpi);
  Ti.API.info('Ti.Platform.displayCaps.ydpi: ' + Ti.Platform.displayCaps.ydpi);
}

# Properties

# density READONLY

Availability
0.8
0.8
9.2.0
density :String

Logical density of the display.


# dpi READONLY

Availability
0.8
0.8
9.2.0
dpi :Number

Display density expressed as dots-per-inch.


# logicalDensityFactor READONLY

Availability
0.8
3.4.1
9.2.0
logicalDensityFactor :Number

Logical density of the display, as a scaling factor for the Density Independent Pixel (dip) unit.

One dip is one pixel on a 160dpi display, approximately, with a 240x320, 1.5"x2" display providing a baseline. For example, for a 160dpi display, this value will be 1, and for 120dpi, it will be .75.

This value does not precisely follow the real display size, as given by xdpi and ydpi, but instead is used to scale the size of the overall UI in steps based on changes in the display dpi. For example, a 240x320 screen will have a density of 1, whether its width is 1.8" or 1.3". However, if the resolution is increased to 320x480 but the display remains 1.5"x2" then the density would be increased to about 1.5.

On iOS devices, this property returns 1, 2 and 3 for @1x, @2x and @3x respectively. Note for iPhone 6+, this value is 3.


# platformHeight READONLY

Availability
0.8
0.8
9.2.0
platformHeight :Number

Absolute height of the display in relation to UI orientation. Measured in platform-specific units; pixels on Android and density-independent pixels (dip) on iOS.

This property depends on the orientation of the UI, rather than the physical orientation of the device. While these may often be one in the same, it is not necessarily the case when orientation is restricted by orientationModes. See example for clarification.


# platformWidth READONLY

Availability
0.8
0.8
9.2.0
platformWidth :Number

Absolute width of the display in relation to UI orientation. Measured in platform-specific units; pixels on Android and density-independent pixels (dip) on iOS.

This property depends on the orientation of the UI, rather than the physical orientation of the device. While these may often be one in the same, it is not necessarily the case when orientation is restricted by orientationModes. See example for clarification.


# xdpi READONLY

Availability
0.8
xdpi :Number

Physical pixels per inch of the display in the X dimension.


# ydpi READONLY

Availability
0.8
ydpi :Number

Physical pixels per inch of the display in the Y dimension.