Question

We are developing a mobile app for android, ios and mobile web using Titanium. We need the exact device height on some of our functionalities. We used Ti.Platform.DisplayCaps.platformHeight to get the device height and it is working just fine on ios and mobileweb. But on android, it returns a very huge number. It is returning 1059, which very big number. When we do a view for example with height : 400, it is already 60% of the screen.

Your help will be appreciated.

Thanks!

Was it helpful?

Solution

I've just come across the same "thing" in my app the problem is that the function Ti.Platform.DisplayCaps.platformHeight on android returns the value in pixel but in iOs is Dpi.

as workaround for this discrepancy I've put thi in my app:

if (osname == 'android')
{
    densityMultiplier = Ti.Platform.displayCaps.logicalDensityFactor;
}
if (osname == 'iphone')
{
    densityMultiplier = 1;
}

and to set the hight of the view:

$.myView.setHight(newHight * densityMultiplier)

I hope this is helpful.

Jaba81

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top