Titanium JIRA Archive
Appcelerator Community (AC)

[AC-2457] Ti.Platform.displayCaps.platformWidth gives the wrong value when default points pixels

GitHub Issuen/a
TypeBug
Priorityn/a
StatusClosed
ResolutionInvalid
Resolution Date2013-01-02T20:07:12.000+0000
Affected Version/sn/a
Fix Version/sn/a
Componentsn/a
Labelsn/a
ReporterOleg Polyakov
AssigneeDaniel Sefton
Created2012-12-21T18:22:35.000+0000
Updated2016-03-08T07:41:30.000+0000

Description

If you change the position (left) of parent View the child views will start shrinking. I have been told to use //$.container.width=Ti.Platform.displayCaps.platformWidth; However, Ti.Platform.displayCaps.platformWidth gives me 320 on retina display. I need 640 for this to work. I am using everything in pixels as I defined in tiapp.xml Why cannot platformWidth give me 640 which is the true width in pixels? Is it a bug?

Comments

  1. Daniel Sefton 2013-01-02

    platformWidth/Height returns the display units. Here's how to convert those to pixels:
       function DPUnitsToPixels(TheDPUnits)
       {
         return (TheDPUnits * (Titanium.Platform.displayCaps.dpi / 160));
       }
       
       // If platformWidth is 320, it converts it to 640
       DPUnitsToPixels(Titanium.Platform.DisplayCaps.platformWidth);
       
    Closing as invalid.

JSON Source