Saturday, 15 June 2013

Titanium Window Animations

In Android, Titanium windows can be heavyweight or lightweight:

- A heavyweight window is associated with a new Android Activity. Creating a heavyweight window always creates a new JavaScript context.

- A lightweight window is a fullscreen view, and runs in the same Android Activity as the code that created it. Creating a lightweight window creates a new JavaScript context if it was created with the 'url' property set.

Heavyweight Window Transitions in Android

Heavyweight windows are their own Android Activity.
The only way to animate the opening of an Activity in Android is to apply an animation resource to it. Passing a Titanium.UI.Animation object as a parameter to open will have no effect if the window being opened is heavyweight and thus opens its own Activity.

Instead, in the parameter dictionary you pass to open, you should set the activityEnterAnimation and activityExitAnimation keys to animation resources.

  • The activityEnterAnimation should be set to the animation you want to run on the new window (activity) 
  • The activityExitAnimation should be set to the animation you want to run on the window (activity) that you are leaving as you open the new heavyweight window above it.
Just chek Below Sample :

Sample For Window Animation

You can also create Custom animation for Window.

Custom animation For Titanium window :

Follow Below Steps :
  1. Create your own animation resource XML files.see "View Animation" in Android's Resources documentation.
  2. After creating an Animation resource file, you can place it under platform/android/res/anim in your Titanium project folder and it will be packaged in your app's APK and then available via Titanium.App.Android.R.

    Custom Window animation
  3. Here is the my Animation file :

1 comment:

  1. Hii Jigar ,
    I tried animation for slide_up and slide_down the window with this and it's work fine.
    1. But when I set only activityEnterAnimation : Titanium.App.Android.R.anim.slide_in_bottom, property for closing second window at that time first(behind second window) jumped with second window at bottom and than display.

    2. And when I set both activityEnterAnimation, activityExitAnimation property for closing second window at that time black background appear for a second and than second window closed.

    can we stop jumping first window ? or can we stop black background that appear for a second ?

    please help.