Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-8891] Android: scrollView not scrolling if contentHeight = 'auto'

GitHub Issuen/a
TypeBug
PriorityCritical
StatusClosed
ResolutionFixed
Resolution Date2012-07-04T03:07:49.000+0000
Affected Version/sRelease 2.1.0
Fix Version/sRelease 2.1.0, Sprint 2012-09 Core
ComponentsAndroid
Labelscore, module_scrollview, qe-testadded
ReporterJon Alter
AssigneeAllen Yeung
Created2012-04-25T15:31:20.000+0000
Updated2012-07-16T23:42:54.000+0000

Description

scrollView not scrolling if contentHeight = 'auto' and height of the childView of scrollView is set to SIZE. It works fine if you set the height of the childView to something static instead of SIZE

Steps to repro

Step 1: run code Step 2: try to scroll (if it doesn't scroll then it is still broken)
var win = Ti.UI.createWindow();
win.open();

var scrollView = Ti.UI.createScrollView({
	contentHeight:'auto',
	backgroundColor: 'green'
});
win.add(scrollView);

var innerView = Ti.UI.createView({
	height:Ti.UI.SIZE, // works if set to 1000
	layout:'vertical',
	left:0,
	top:0,
	right:0
});
scrollView.add(innerView);

var colors = ['red', 'blue', 'pink', 'white', 'black'];

var max = 10;
for(var i = 0; i < max; i++){
	innerView.add(Ti.UI.createView({
		backgroundColor: colors[i%colors.length],
		height: 100,
		top: 20
	}));
}

Comments

  1. Natalie Huynh 2012-06-15

    Tested with Droid 3 2.3.4 with 2.1.0.v20120615104152
  2. Neha Chhabra 2012-07-04

    Reopening to update labels.
  3. Martin Guillon 2012-07-08

    I think commit [76a526da112a1a478e0ac3d78a80e5379b0a06be](https://github.com/appcelerator/titanium_mobile/commit/76a526da112a1a478e0ac3d78a80e5379b0a06be) broke it It s not working anymore.
  4. Allen Yeung 2012-07-13

    This seems to be working for me. Can you please try the latest version of the sdk?
  5. Max Stepanov 2012-07-13

    Verified the example above works fine on current master and 2_1_X branch.
  6. Martin Guillon 2012-07-14

    Ok so it still didnt work for me because i was not using the innerView. SO this would be my example which doesnt work ( works on iphone by the way). Remark the horizontal layout which is very important for me.
       var win = Ti.UI.createWindow();
       win.open();
        
       var scrollView = Ti.UI.createScrollView({
           contentHeight:'auto',
           contentWidth:0,
           layout:'horizontal',
           backgroundColor: 'green'
       });
       win.add(scrollView);
       
       var colors = ['red', 'blue', 'pink', 'white', 'black'];
        
       var max = 120;
       for(var i = 0; i < max; i++){
           scrollView.add(Ti.UI.createView({
               backgroundColor: colors[i%colors.length],
               height: 100,
               left: 10,
               width: 100,
               top: 10
           }));
       }
       
    Now if i try with the innerView it wont work either, but for another reason. This time the innerView wont increase in height. Most obviously due to the horizontal layout.
       var win = Ti.UI.createWindow();
       win.open();
        
       var scrollView = Ti.UI.createScrollView({
           contentHeight:'auto',
           contentWidth:0,
           backgroundColor: 'green'
       });
       win.add(scrollView);
        
       var innerView = Ti.UI.createView({
           height:Ti.UI.SIZE, // works if set to 1000
           layout:'horizontal',
           left:0,
           top:0,
           right:0
       });
       scrollView.add(innerView);
        
       var colors = ['red', 'blue', 'pink', 'white', 'black'];
        
       var max = 120;
       for(var i = 0; i < max; i++){
           innerView.add(Ti.UI.createView({
               backgroundColor: colors[i%colors.length],
               height: 100,
               left: 10,
               width: 100,
               top: 10
           }));
       }
       
  7. Allen Yeung 2012-07-16

  8. Martin Guillon 2012-07-16

    Thanks a lot Allen!

JSON Source