Create a LayoutAnimation xml in the res/anim directory
Something like that:
Name this "anim"
<layoutAnimation
xmlns:android="http://schemas.android.com/apk/res/android"
android:delay="100%"
android:directionPriority="none"
android:animation="@anim/elem"
/>
the anim/elem xml is the one describing each layout element behavior
during the animation:
<set
xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/accelerate_interpolator"
android:fillBefore="true"
>
<alpha
android:fromAlpha="0.2"
android:toAlpha="1.0"
android:duration="100"
/>
<translate
android:fromXDelta="-120%p" android:toXDelta="0"
android:fromYDelta="-40%p" android:toYDelta="0"
android:duration="150"
/>
<scale
android:fromXScale="0.6" android:toXScale="1.0"
android:fromYScale="0.6" android:toYScale="1.0"
android:pivotX="50%" android:pivotY="50%"
android:duration="100"
/>
</set>
the fillBefore atribute is necesary to conserve the view of the layout
after the animation ends.
Then you set the layout atribute "android:layoutAnimation="@+anim/
anim" <- reference to the layout animation, not the element set.
When the activity loads, the animation is then display. You have more
examples in the Api Demos app of the SDK.
To animate the exit of a layout, you define another layout animation
if needed.
Then you put the following in your code:
LayoutAnimationController lac =
AnimationUtils.loadLayoutAnimation(this, R.anim.my exit
layout);
RelativeLayout al = (RelativeLayout)findViewById(R.id.my
layout); <-
It can be another type of layout.
al.setLayoutAnimation(lac);
and override the methods if needed.
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en