Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-9371] Android: Ti.Platform.displayCaps.platformHeight and platformWidth do not work properly on different Android screen resolutions

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionInvalid
Resolution Date2012-06-11T11:34:00.000+0000
Affected Version/sRelease 2.0.0
Fix Version/sn/a
ComponentsAndroid
LabelsSupportTeam, api, parity
ReporterVarun Joshi
AssigneeHieu Pham
Created2012-06-04T17:13:17.000+0000
Updated2012-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

FileDateSize
Screen Shot 2012-06-04 at 5.09.14 PM.png2012-06-04T17:13:17.000+0000191484
Screen Shot 2012-06-04 at 5.12.13 PM.png2012-06-04T17:13:17.000+000076873

Comments

  1. Hieu Pham 2012-06-11

    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.
       var menu = Ti.UI.createView({
           backgroundColor:'blue',
           height: "50dip",
           bottom:0
       });
       
    ```
  2. Hieu Pham 2012-06-11

    Closing bug as invalid
  3. Varun Joshi 2012-06-11

    Closing this ticket as per the above comment.

JSON Source