Created
May 25, 2014 05:32
-
-
Save exclusiveTanim/df27a804e42d707b5cec to your computer and use it in GitHub Desktop.
iOS:Gap between views from ScrollableView
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*Make the scrollableView wider than the device width, make the child views the same width as the device and | |
then the offset the scrollableView with a minus margin equal to half the difference of the two widths. | |
So if we set scrollableView width to 340 and the child views to 320, | |
then the left margin will be -10. Here is a example below.*/ | |
var win = Ti.UI.createWindow({ | |
backgroundColor : '#ccc', | |
title : 'Test' | |
}); | |
var tab = Ti.UI.createTab({ | |
icon : 'KS_nav_views.png', | |
title : 'Test', | |
window : win | |
}); | |
win.setBackgroundColor(Ti.UI.iOS.COLOR_SCROLLVIEW_BACKGROUND); | |
var view1 = Ti.UI.createView({ | |
backgroundColor : '#123', | |
width : 320 | |
}); | |
var view2 = Ti.UI.createView({ | |
backgroundColor : '#246', | |
width : 320 | |
}); | |
var view3 = Ti.UI.createView({ | |
backgroundColor : '#48b', | |
width : 320 | |
}); | |
var scrollableView = Ti.UI.createScrollableView({ | |
left : -10, | |
showPagingControl : true, | |
views : [view1, view2, view3], | |
width : 340 | |
}); | |
win.add(scrollableView); | |
var tabGroup = Ti.UI.createTabGroup(); | |
tabGroup.addTab(tab); | |
tabGroup.open(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment