var win = Titanium.UI.createWindow({ title:"Grouping and Nesting Views", backgroundColor:"#FFFFFF", exitOnClose:true }) //第一, 我们创建一些views 为了把图片和文字显示 var view01 = Titanium.UI.createView({ top:0, left:0, height:75, "100%", backgroundColor:"#97AF22" }); var view02 = Titanium.UI.createView({ top:75, left:0, height:100, "100%", backgroundColor:"#533436" }); var view03 = Titanium.UI.createView({ top:175, left:50, height:75, 150, backgroundColor:"#082D35" }); var view04 = Titanium.UI.createView({ top:250, left:"50%", height:100, "50%", backgroundColor:"#9D3844" }); //第二 var img01 = Titanium.UI.createImageView({ image:"images/box01.png", top:0, //记住: 是相对于上层母容器 left:0, 75, height:75, }); var label01 = Titanium.UI.createLabel({ text:"Label 01", left:82, textAlign:"left", color:"#000000" }) view01.add(img01); view01.add(label01); var img02 = Titanium.UI.createImageView({ image:"images/box02.png", top:0, left:20, 75, height:75, }); var label02 = Titanium.UI.createLabel({ text:"Label 02", left:122, textAlign:"right", color:"#000000" }) view02.add(img02); view02.add(label02); var img03 = Titanium.UI.createImageView({ image:"images/box03.png", top:0, right:0, 75, height:75, }); var label03 = Titanium.UI.createLabel({ text:"Label 03", left:0, textAlign:"left", color:"#000000" }) view03.add(img03); view03.add(label03); var img04 = Titanium.UI.createImageView({ image:"images/box04.png", top:0, right:0, 75, height:75, }); var label04 = Titanium.UI.createLabel({ text:"Label 04", bottom:0, left:0, height:20, textAlign:"left", color:"#000000" }) view04.add(img04); view04.add(label04); win.add(view01); win.add(view02); win.add(view03); win.add(view04); win.open();