2016年1月11日 星期一

Custom Animation on Android

To add custom window animation
1. create /platform/android/res/anim/{animation_name}.xml
e.g. animate left_to_right.xml
<?xml version="1.0" encoding="utf-8"?><set xmlns:android="http://schemas.android.com/apk/res/android">
    <translate android:fromXDelta="0%" android:toXDelta="100%" android:duration="300"/><alpha android:fromAlpha="1.0" android:toAlpha="0" android:duration="300" /></set>


2. In window.open, add property:
win.open({activityEnterAnimation: Ti.App.Android.R.anim.right_to_left});
Or, in window.close

win.close({activityExitAnimation: Ti.App.Android.R.anim.right_to_left });


Reminder: Don't miss out the App. Appcerator built-in animation prefix Ti.Android.R.anim.xxxx


Reference: 
http://developer.android.com/guide/topics/resources/animation-resource.html#View

沒有留言:

張貼留言