Titanium Android:如何为模态窗口设置动画?
我正在 Titanium 上开发 Android 应用程序。在此应用程序中,我需要打开一个模态窗口,其中有以下代码。
var window = Ti.UI.createWindow({
title: "This is modal window"
});
// Add some elements to window
window.open({modal: true});
这里的问题是窗口会在没有任何动画的情况下立即打开。我想让模态窗口在出现在屏幕上时从下到上爬行。我怎样才能实现这个动画?我也曾在 window.open() 中设置过动画:true,但没有成功。
I am developing an app for android on Titanium. In this app, I need to open a modal window for which I have the following code.
var window = Ti.UI.createWindow({
title: "This is modal window"
});
// Add some elements to window
window.open({modal: true});
The problem here is that the window opens in a flash without any animation. I would like to have the modal window crawl from bottom to top while appearing on screen. How can I carry out this animation? I have also trued giving animation:true in window.open(), but didn't succeed.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
默认情况下,Android 中没有“从下到上”动画。默认情况下,您可以通过创建“重量级”窗口获得“从右到左”动画。请参阅 http://developer.appcelerator.com/doc/mobile/android/module_sdk 的底部
但是,SDK 1.7.5 中似乎存在一个错误,因此在创建时设置窗口的
modal:true
属性默认情况下不会显示动画。但是您可以使用上面链接中描述的任何其他属性来制作重量级窗口,并且动画将会显示。以下代码将显示 Android 2.1 和 Appcelerator Mobile 1.7.5 中打开的默认动画窗口:如果将
animated:true
更改为animated:false
,则窗口将只是在您打开和关闭时出现和消失。你可以尝试创建自己的动画,在打开窗口时将窗口从底部向上滑动,但我从未在 Android / Appcelerator 上尝试过。
There is no 'bottom to top' animation in Android by default. You can get a 'right to left' animation by default by creating a 'heavyweight' window. See the bottom of http://developer.appcelerator.com/doc/mobile/android/module_sdk
However, there seems to be a bug in 1.7.5 of the SDK so setting the
modal:true
property of a window on creation will not show the animation by default. But you can use any of the other properties described in the link above to make a heavyweight window and the animation will show. Here is some code that will show a default animation window opening in Android 2.1 and Appcelerator Mobile 1.7.5:If you change the
animated:true
toanimated:false
the window will just appear and disappear when you open and close.You could try to create your own animation to slide the window up from the bottom when opening the window, but I have never tried that on Android / Appcelerator.