[TIMOB-8243] Android: ScrollView - If a view is added to a scrollview, the view will not fill the screen
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Medium |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2012-07-12T04:16:42.000+0000 |
Affected Version/s | Release 2.0.0 |
Fix Version/s | Release 2.1.0, Sprint 2012-08 |
Components | Android |
Labels | api, module_scrollview, parity, qe-and031912, qe-nfc, qe-testadded |
Reporter | Wilson Luu |
Assignee | Allen Yeung |
Created | 2012-03-23T12:34:01.000+0000 |
Updated | 2012-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
File | Date | Size |
---|---|---|
droid.png | 2012-03-25T12:01:41.000+0000 | 36350 |
ios.png | 2012-03-25T12:01:41.000+0000 | 22073 |
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.
Also occurs on: Titanium Studio, build: 2.0.0.201203262445 SDK: 2.0.0.v20120325213306 Android Nexus S (2.3.6)
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
Also occurs on Kindle Fire and Nook Color Titanium SDK: 2.0.0.v20120325213306 Titanium Studio, build: 2.0.0.201203262445
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)
Re-opening to edit label