Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-11707] scrollableView height property set to Ti.UI.SIZE causes view to not display at all

GitHub Issuen/a
TypeBug
Priorityn/a
StatusClosed
ResolutionFixed
Resolution Date2012-11-13T19:47:26.000+0000
Affected Version/sn/a
Fix Version/sRelease 3.1.0, 2012 Sprint 23 API, 2012 Sprint 23
ComponentsiOS
Labelsios, iphone, qe-port, scrollableView, sdk2.0.1GA2
ReporterHenning Glatter-Gotz
AssigneeVishal Duggal
Created2012-05-26T12:00:38.000+0000
Updated2013-01-18T02:39:35.000+0000

Description

Setting the height property in scrollableView to Ti.UI.SIZE hides the view (probably sets height to 0). The expected effect would be to have the scrollableView height adjust to the height of its contents or at least the default height (fit on screen). The only way to get the scrollable view to display larger than the screen is to explicitly set its height with an integer value. This is not always possible or desirable since the content height might be unknown and computing it "by hand" with toImage() is costly. The code example below has a variety of height values to demonstrate the different scenarios (uncomment as needed):
var win = Ti.UI.createWindow({
    title:'ScrollableView'
});
 
var scrollView = Ti.UI.createScrollView({
    top:0,
    left:0,
    backgroundColor:'#f1f1f1',
    width:Ti.UI.FILL,
    height:Ti.UI.FILL,
    contentWidth:'auto',
    contentHeight:'auto',
    showVerticalScrollIndicator: true,
    showHorizontalScrollIndicator: false,
    layout:'vertical'
});
 
var lab = Ti.UI.createLabel({
    color:'#2a2a2a',
    height:44,
    width:Ti.UI.SIZE,
    top:12,
    left:12,
    right:12,
    text:'Not working as expected',
    textAlign:'left',
    font:{fontFamily:'HelveticaNeue',fontSize:16,fontWeight:'normal'}
});
 
var views = [];
 
var v1 = Ti.UI.createView({
    top:0,
    width:'100%',
    height:300,
    backgroundColor:'red'
});
 
views.push(v1);
 
var v2 = Ti.UI.createView({
    top:0,
    width:'100%',
    height:600,
    backgroundColor:'green'
});
 
var lab2 = Ti.UI.createLabel({
    top:370,
    left:60,
    right:60,
    text:'Scroll me up to see how I get cut off'
});
 
v2.add(lab2);
views.push(v2);
 
var scrollableView = Ti.UI.createScrollableView({
    top:0,
    views:views,
    showPagingControl:false,
    // height:'auto'     // This is probably the default because
                         // it has no affect
    // height:Ti.UI.FILL // This is probably the default because
                         // it has no affect
    // height:Ti.UI.SIZE // If you add this the hight sets to 0
    // height:700        // This works and will make the
                         // scrollableView fit its contents, but
                         // requires that the height of the contents
                         // is known, which is not the case in this app
});
 
scrollView.add(lab);
scrollView.add(scrollableView);
scrollView.add(Ti.UI.createView({top:0,width:Ti.UI.FILL,height:20}));
win.add(scrollView);
win.open();

Attachments

FileDateSize
iOSSim.jpg2012-10-11T20:28:27.000+000046451

Comments

  1. Daniele Mantovani 2012-06-12

    Any news? I've the same problem and could not continue the application without solving that. If I use the postrender and scroll event, catch the current view height and assign to the scrollableview height, could be a solution?
  2. Daniel Sefton 2012-10-11

    Tested and confirmed on iOS 5.1 and 6 with TiSDK 2.1.2 GA, 2.1.3 GA and 3.0.0.
  3. Eduardo Gomez 2012-10-11

  4. Vishal Duggal 2012-11-08

    Not Fixed.
  5. Vishal Duggal 2012-11-08

    Pull pending https://github.com/appcelerator/titanium_mobile/pull/3396
  6. Anshu Mittal 2013-01-18

    Tested with: SDK:3.1.0.v20130114171802 Studio:3.0.1.201212181159 Device: iPhone3GS(v5.0.1)

JSON Source