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

Android: Scroll View Touch Listeners Prevent Scrolling

    Details

      Description

      Problem

      Adding a touch listener to a scroll view on Android prevents the scroll view from being scrollable. Although the events do then fire, they fire with the scroll view always as the source. This is inconsistent with iOS.

      Expected Behavior

      It should behave as iOS does. The events should fire, and the scroll view should scroll. Further, the source should be the most deeply child touchable view, like on iOS.

      Reproduction

      Drop the following in an app.js. It adds a vertically scrollable list of draggable rectangles. On iOS, you can drag them horizontally. On Android, you can't drag them anywhere, or even scroll the scroll view.

      app.js

      var win = Ti.UI.createWindow({
          backgroundColor: '#fff'
      });
      var scroll = Ti.UI.createScrollView({
          scrollType: 'vertical',
          contentHeight: 3010,
          text: 'Scroll View'
      });
      var width = 150, height = 90;
      for (var i = 0; i < 30; i++) {
          scroll.add(Ti.UI.createLabel({
              draggable: true,
              text: 'Drag Me Horizontally ' + (i + 1), textAlign: 'center',
              color: '#000',
              top: i * 100 + 10,
              width: width, height: height,
              backgroundColor: '#eee'
          }));
      }
      scroll.addEventListener('touchstart', doDrag);
      scroll.addEventListener('touchmove', doDrag);
      scroll.addEventListener('touchcancel', doDrag);
      scroll.addEventListener('touchend', doDrag);
      function doDrag(evt) {
          Ti.API.info('Event Fired On: ' + evt.source.text);
          if (evt.source.draggable) {
              var global = evt.source.convertPointToView({ x: evt.x, y: evt.y }, scroll);
              evt.source.updateLayout({
                  left: global.x - width / 2
              });
          }
      }
      win.add(scroll);
      win.open();
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                ayeung Allen Yeung
                Reporter:
                dtoth Dawson Toth
              • Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Backbone Issue Sync

                  • Titanium SDK/CLI <> Titanium Mobile
                    Synced with:
                    TIMOB-13411
                    Sync status:
                    ERROR
                    Last received:
                    Last sent:

                    Git Integration