Uploaded image for project: 'Titanium SDK/CLI'
  1. Titanium SDK/CLI
  2. TIMOB-25557

Android: View rect x and y are inconsistent

    Details

    • Type: Bug
    • Status: Closed
    • Priority: High
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: Release 7.1.0
    • Component/s: Android
    • Labels:
    • Environment:

      From SDK 6.0.3 to 6.3.0

    • Story Points:
      1
    • Sprint:
      2017 Sprint 26 SDK, 2018 Sprint 01 SDK, 2018 Sprint 02 SDK, 2018 Sprint 03 SDK

      Description

      I have a problem on Android with View.rect object which returns x;y as absolute position in window.
      This behaviour is inconsistent with iOS and the documentation which says "The bounding box of the view relative to its parent, in system units.

      The view's bounding box is defined by its size and position.

      The view's size is rect.width x rect.height. The view's top-left position relative to its parent is (rect.x , rect.y)."

      This is since the https://jira.appcelerator.org/browse/TIMOB-24442 bugfix

      The commit that introduced the wrong behaviour is
      https://github.com/appcelerator/titanium_mobile/commit/db9a1ccf960f96e6eb671619560015cb5c65dead

      var vw = Ti.UI.createView({
          top: 100,
          left: 100,
          width: 200,
          height: 200,
          backgroundColor: "blue"
      });
       
      var inner = Ti.UI.createView({
          top: 20,
          left: 20,
          width: 30,
          height: 30,
          backgroundColor: "yellow"
      });
       
      vw.add(inner);
       
      $.index.add(vw);
       
      $.index.addEventListener('click', function (e) {
          if (OS_IOS) {
              Ti.API.info('Rect : ' + JSON.stringify({x: e.source.rect.x, y: e.source.rect.y, width: e.source.rect.width, height: e.source.rect.height}));        
          } else {
              Ti.API.info('Rect : ' + JSON.stringify(e.source.rect));
          }
      });
       
      $.index.open();
      

      Procedure :

      • click on the white zone (e.source = $.index)
      • click on the blue zone (e.source = vw)
      • click on the yellow zone (e.source = inner)

      iOS log :

      [INFO] :   Rect : {"x":0,"y":0,"width":414,"height":736}
      [INFO] :   Rect : {"x":100,"y":100,"width":200,"height":200}
      [INFO] :   Rect : {"x":20,"y":20,"width":30,"height":30}
      

      Android log :

      [INFO] :   Rect : {"height":603,"width":411,"y":80,"x":0}
      [INFO] :   Rect : {"height":200,"width":200,"y":180,"x":100}
      [INFO] :   Rect : {"height":30,"width":30,"y":200,"x":120}
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                gmathews Gary Mathews
                Reporter:
                gduthieuw Guile
                Reviewer:
                Lokesh Choudhary
              • Watchers:
                5 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Backbone Issue Sync

                  • It looks like Backbone Issue Sync is not enabled for your project.

                    Git Source Code