ScrollView - mobileweb vs iphone discrepancy
When adding views to a ScrollView where contentWidth = Ti.UI.SIZE and contentHeight = Ti.Ui.SIZE,
the view is added to the top left indicating the contentView is the same size as the newly added view instead of
filling most space of the scrollview. This also occurs if contentWidth and contentHeight are left blank.
The reason this is an issue is because it acts differently than iOS on iPhone. On iPhone, the view will be centered in the scrollview.
The importance for using Ti.UI.SIZE is for the contentView to expand upon it's content so that it can scroll
and not be a fixed view within the scrollview.
Steps to reproduce:
1. Copy the code below into a new project
2. Run on iPhone emulator
Note the purple square in the center of the grey scrollview
3. Run on mobileweb
Note the purple square at the top left of the grey scrollview
CODE:
var win1 = Titanium.UI.createWindow({
backgroundColor:'#fff'
});
var scrollview = Ti.UI.createScrollView({
contentWidth: Ti.UI.SIZE,
contentHeight: Ti.UI.SIZE,
width: 200,
height: 300,
backgroundColor: '#444'
});
var view = Ti.UI.createView({
width: 20,
height: 20,
backgroundColor: '#F0F',
});
//Workaround
// scrollview.contentWidth = scrollview.width;
// scrollview.contentHeight = scrollview.height;
scrollview.add(view);
win1.add(scrollview);
win1.open();
Workaround
1. Use the code above but uncomment the lines below '//Workaround'
Sets contentWidth to width of the scrollview
Sets contentHeight to height of the scrollview
This works as it should on iPhone
Closing ticket due to time passed and lack of progress in the past few years. Any problems, please file a new ticket.