如何获得像滚动视图中的窗口元素的过渡?

我想在Appcelerator中做一个Demo,这里是它的代码。

var tabGroup = Titanium.UI.createTabGroup(); var main_win = Titanium.UI.createWindow({ title:'Tab 1', backgroundColor:'#fff' }); var win1 = Titanium.UI.createWindow({ title:'Tab 1', backgroundColor:'#fff' }); var tab1 = Titanium.UI.createTab({ title:'Tab 1', window:win1 }); var label1 = Titanium.UI.createLabel({ text:'I am Window 1', win:win1 }); win1.add(label1); var win2 = Titanium.UI.createWindow({ title:'Tab 2', backgroundColor:'#fff' }); var tab2 = Titanium.UI.createTab({ title:'Tab 2', window:win2 }); var label2 = Titanium.UI.createLabel({ text:'I am Window 2', }); win2.add(label2); tabGroup.addTab(tab1); tabGroup.addTab(tab2); main_win.open(); var button1 = Titanium.UI.createButton({ title:"hello" }); main_win.add(button1); var button2 = Titanium.UI.createButton({ title:"hello" }); win1.add(button2); button1.addEventListener('click', function(e) { tabGroup.open(); }); button2.addEventListener('click', function(e) { main_win.show(); tabGroup.close(); }); 

现在button2不能以所需的方式工作。 我想切换回window_1即主窗口。 代码出了什么问题。

编辑

我想有一个窗口(可以是一个视图/窗口或其他东西),即main_win有一个名为button1的button。 当我点击button1时,它移动到另一个视图,它显示了两个与tab1tab2相关联的选项卡视图,即win1win2 。 点击tab1将显示win1 ,点击tab2将显示win2win1win2都有一个button说button2点击哪个会把我们发回main_win 。 此外,我希望过渡是像我们从默认情况下滚动视图。

我总是把tabGroups看成是windows。 它没有记录,但是您可以在Android中的exitOnClose上使用exitOnClose属性。 请看下面的代码是否做你需要的。 针对Android 2.2的Titanium SDK 1.7.5

 var main_win = Titanium.UI.createWindow({ title : 'main_win', backgroundColor : '#fff' }); var button1 = Titanium.UI.createButton({ title : "open tabGroup", height:35, width:120 }); button1.addEventlistner('click', function(e) { tabGroup.open(); }); main_win.add(button1); var win1 = Titanium.UI.createWindow({ title : 'Tab 1', backgroundColor : '#fff' }); var tab1 = Titanium.UI.createTab({ title : 'Tab 1', window : win1 }); var label1 = Titanium.UI.createLabel({ text : 'I am Window 1', win : win1 }); win1.add(label1); var button2 = Titanium.UI.createButton({ title : "< back", top:5, left:5, height: 35, width: 80 }); win1.add(button2); button2.addEventlistner('click', function(e) { tabGroup.close(); }); var win2 = Titanium.UI.createWindow({ title : 'Tab 2', backgroundColor : '#fff' }); var tab2 = Titanium.UI.createTab({ title : 'Tab 2', window : win2 }); var label2 = Titanium.UI.createLabel({ text : 'I am Window 2', }); win2.add(label2); var button3 = Titanium.UI.createButton({ title : "< back", top:5, left:5, height: 35, width: 80 }); win2.add(button3); button3.addEventlistner('click', function(e) { tabGroup.close(); }); var tabGroup = Titanium.UI.createTabGroup({ exitOnClose: false }); tabGroup.addTab(tab1); tabGroup.addTab(tab2); main_win.open(); 

选项卡组是一个全局元素。 我不知道是否有可能关闭它 – 显然不是。 你可以跳转到一个标签

 tabGroup.setActiveTab(id_of_your_tab); 

你需要建立自己的酒吧,如果你必须隐藏它。

另外,是否可以为视图或滚动视图制作标签视图。

你可以在窗口上使用滚动视图 :

 var scrollView = Titanium.UI.createScrollView({ contentWidth:'auto', contentHeight:'auto', top:0, showVerticalScrollIndicator:true, showHorizontalScrollIndicator:true }); var view = Ti.UI.createView({ backgroundColor:'#336699', borderRadius:10, width:300, height:2000, top:10 }); scrollView.add(view); Titanium.UI.currentWindow.add(scrollView); 

tableviews也是实现可滚动视图的常用方法。

在为Android设备制作应用程序时,还可以使用其他什么选项。

看看钛api 。 它显示Android上可用的方法和视图。 你也应该知道Android设备的多密度。 所以你需要以多种分辨率提供你的图像。 看看钛的指导方针 。

希望能帮助到你