Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-8243] Android: ScrollView - If a view is added to a scrollview, the view will not fill the screen

GitHub Issuen/a
TypeBug
PriorityMedium
StatusClosed
ResolutionFixed
Resolution Date2012-07-12T04:16:42.000+0000
Affected Version/sRelease 2.0.0
Fix Version/sRelease 2.1.0, Sprint 2012-08
ComponentsAndroid
Labelsapi, module_scrollview, parity, qe-and031912, qe-nfc, qe-testadded
ReporterWilson Luu
AssigneeAllen Yeung
Created2012-03-23T12:34:01.000+0000
Updated2012-07-12T14:23:26.000+0000

Description

Steps to reproduce: 1. Run the following code on Android:
//Create a Ti.UI.View with scroll view and do not put any content 

var win = Ti.UI.createWindow();
win.backgroundColor = 'white';

var label = Ti.UI.createLabel({
	text: 'View Size is: ',
	top: 20,
	left: 10,
	height: Ti.UI.SIZE,
	width: Ti.UI.SIZE,
	color: 'black'
});

var scrollView = Titanium.UI.createScrollView({
    contentHeight:'auto',
    contentWidth:'auto',
    showVerticalScrollIndicator:true,
    showHorizontalScrollIndicator:true
});

var view = Ti.UI.createView();

var view2 = Ti.UI.createView({
	backgroundColor:'red'
})

scrollView.add(view2);

win.addEventListener('postlayout', function layoutHandler(e) {
	win.removeEventListener('postlayout', layoutHandler);
	label.text = 'ScrollView\'s height and width: ' + scrollView.size.height + 'x' + scrollView.size.width + '\n' +
	             'Screen\'s height and width: ' + win.size.height + 'x' + win.size.width;
	win.addEventListener('postlayout', layoutHandler);
});

win.add(scrollView);
win.add(view);
view.add(label);

win.open();

Actual: A white view appears. Expected: A red view should fill the screen similarly to iOS. See attachments

Attachments

FileDateSize
droid.png2012-03-25T12:01:41.000+000036350
ios.png2012-03-25T12:01:41.000+000022073

Comments

  1. Wilson Luu 2012-03-25

    After further investigation, this bug could be related to the layout feature. In the previous sample code, it did not contain the postlayout event which will display the ScrollView's height and width = 0. Now, the current sample code contains the postlayout event which properly displays the ScrollView's height and width.
  2. Tamila Smolich 2012-03-26

    Also occurs on: Titanium Studio, build: 2.0.0.201203262445 SDK: 2.0.0.v20120325213306 Android Nexus S (2.3.6)
  3. Sitara Shylaja 2012-03-26

    This also occurs on Android(2.2.2) Nexus one when tested on Titanium mobilesdk-2.0.0.v20120325213306 Titanium Studio build: 2.0.0.201203262445
  4. Satyam Sekhri 2012-03-26

    Also occurs on Kindle Fire and Nook Color Titanium SDK: 2.0.0.v20120325213306 Titanium Studio, build: 2.0.0.201203262445
  5. Smitha Guduru 2012-06-23

    A red view appears on the screen. Verified on Titanium Studio, build: 2.2.0.201206222035 Titanium SDK: 2.1.0.v20120622174154 Device:Xoom(4.0.3)
  6. Shyam Bhadauria 2012-07-12

    Re-opening to edit label

JSON Source