-
Book Overview & Buying
-
Table Of Contents
Appcelerator Titanium Application Development by Example Beginner's Guide
By :
A window, or as it is named in the code, Titanium.UI.Window, is the canvas on which all other elements are attached. Without a window there can be no sliders, no buttons, nothing. All app elements are attached (or to use the Titanium terminology, added) to a window using the add command. An app requires at least one window to function and that window must be called from within the app.js file. The following code sample shows how a label is created and added to a window.
var win1 = Titanium.UI.createWindow({
title:'Tab 1',
backgroundColor:'#fff'
});
var label1 = Titanium.UI.createLabel({
color:'#999',
text:'I am Window 1',
font:{fontSize:20,fontFamily:'Helvetica Neue'},
textAlign:'center',
width:'auto'
});
win1.add(label1);
A reference to Titanium.UI.createWindow is the same as Ti.UI.createWindow. Ti is a useful shortcut that is built into Titanium that will be used throughout the book.
In the app created in the last chapter there are two windows, one...
Change the font size
Change margin width
Change background colour