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 :






Installing Android App to SD Card From Titanium


- Android apps are installed by default to the device's internal storage. But that Limited memory space can filled fast and quick in older devices .

- You can configure your Titanium apps to install to the SD card.

- To do so, you need to modify the AndroidManifest.xml configuration file.
Titanium makes this easy: you simply update your tiapp.xml file and Studio will take care of creating the necessary manifest file.
Locate the <android> node near the end of that file.
You'll need to add a couple of properties and tags. When you're done, it should look like this:


Now Build and Deploy your app to Device.


Let's go over that code, because you can control a few options. First, the <tool-api-level> node specifies the version of the Android development tools that will be used to compile your app's code. At minimum, you must specify version 8. Higher (newer) versions aren't necessary for installing to the SD card, but perhaps offer other benefits.
Next, is the <manifest> node and the <code>android:installLocation</code> property. You'd choose one of these values for that property:
  • android:installLocation="preferExternal" -- specifies that you prefer your app to install to the SD card, but if one isn't present the app can be installed to internal storage.
  • android:installLocation="auto" – specifies that the phone's configuration will determine the installation location. Generally, your app will be installed to internal storage if sufficient space is available. In that case, users could still move your app by opening Settings > Applications > Manage applications, tapping your app, and tapping Move to SD card.
  • android:installLocation="internalOnly" – which specifies that your app cannot be installed to the SD card. See the Android docs for the various reasons why you might choose this option.
Finally, you need to add the <uses-sdk> tag within the <manifest> node. This tag specifies that your app requires Google's version 7 or newer APIs — in other words, the phone must be running Android 2.1 Update 1 or newer. That pretty much covers all the newer phones, but will exclude some older devices. On those phones, your app will install to the internal storage.