[TIMOB-9371] Android: Ti.Platform.displayCaps.platformHeight and platformWidth do not work properly on different Android screen resolutions
GitHub Issue | n/a |
Type | Bug |
Priority | High |
Status | Closed |
Resolution | Invalid |
Resolution Date | 2012-06-11T11:34:00.000+0000 |
Affected Version/s | Release 2.0.0 |
Fix Version/s | n/a |
Components | Android |
Labels | SupportTeam, api, parity |
Reporter | Varun Joshi |
Assignee | Hieu Pham |
Created | 2012-06-04T17:13:17.000+0000 |
Updated | 2012-06-11T12:43:37.000+0000 |
Description
Problem
Please run the sample code below:
{noformat}
var win = Ti.UI.createWindow({
backgroundColor: '#333'
});
var menu = Ti.UI.createView({
backgroundColor:'blue',
top:Ti.Platform.displayCaps.platformHeight-50,
bottom:0
});
menu.addEventListener('touchmove', function(evt) {
var point = menu.convertPointToView({ x: evt.x, y: evt.y }, win);
menu.top = point.y;
});
menu.addEventListener('touchend', function(e){
if(menu.top <((Ti.Platform.displayCaps.platformHeight/2)+100) && menu.top >((Ti.Platform.displayCaps.platformHeight/2))){
menu.top = Ti.Platform.displayCaps.platformHeight/2;
} else if (menu.top >(Ti.Platform.displayCaps.platformHeight/2)+100){
menu.top = Ti.Platform.displayCaps.platformHeight-50;
} else if (menu.top <((Ti.Platform.displayCaps.platformHeight/2))){
menu.top = 100;
}
})
win.add(menu);
win.open();
{noformat}
In iOS, you see the blue draggable view alright but in Android, depending on the screen size the view is not visible. I tested with QVGA (where it works) and HVGA(where it does not work) avd screens. Please see the attached screenshot too.
Attachments
This isn't a bug on Android. platformHeight and Width return the measurements of the screen (including notification bar and title bar), while "top" and "bottom" properties are relative to the parent view. The parent view's height will always be smaller than the platformHeight because of the app's title bar and/or the notification bar. In iOS, platformHeight and Width returns the screen measurements with NavBar included. Thus the sample code above will not work correctly in iOS. It will report a height of 30 dip, not 50 dip. With that said, it's not a good idea to use platformHeight and Width to determine the height of views. Instead, the same behavior can be achieved by setting bottom to 0 and height to some dip value.
```
Closing bug as invalid
Closing this ticket as per the above comment.