AnimationSet set = new AnimationSet(true); Animation animation = new AlphaAnimation(0.0f, 1.0f); animation.setDuration(50); set.addAnimation(animation);
Construct animation controller LayoutAnimationController controller = new LayoutAnimationController(set, 0.5f);
Set animation ListView listView = getListView(); listView.setLayoutAnimation(controller);
ViewGroup Animation - Specify animation in resource file.
Define view animation For ListView: slide_right.xml android:duration="@android:integer/config_shortAnimTime" />
For GridView: fade.xml android:interpolator="@android:anim/accelerate_interpolator" android:fromAlpha="0.0" android:toAlpha="1.0" android:duration="@android:integer/config_longAnimTime" />
Define layoutAnimation (You can find all available attributes of layoutAnimation/gridLayoutAnimation in android.R.styleable)
For ListView: layout_bottom_to_top_slide.xml android:delay="30%" android:animationOrder="reverse" android:animation="@anim/slide_right" />
For GirdView: layout_grid_fade.xml android:rowDelay="50%" android:directionPriority="column" android:animation="@anim/fade" />
Use layoutAnimation For ListView: android:id="@android:id/list" android:layout_width="match_parent" android:layout_height="match_parent" android:layoutAnimation="@anim/layout_bottom_to_top_slide" />
For GridView: android:layoutAnimation="@anim/layout_grid_fade"
Property Animation Introduced in Android 3.0, the property animation system allows you
to animate almost anything (Views and non-Views). You can define an animation to change any object property (a field in
an object, such as position property x of view) over time, regardless of whether it
draws to the screen or not.
Activity Animation Start target activity in an activity subclass as following:
startActivity(intent);
overridePendingTransition(R.anim.xxx, R.anim.xxx);