One, the use of Android provided by the left and right mobile tool class: Animationutils
LinearLayout Ll_first = (linearlayout) Findviewbyid (r.id.ll_first); LinearLayout Ll_second = (linearlayout) Findviewbyid (r.id.ll_second); Ll_first.setvisibility (view.gone); Ll_second.setvisibility (view.visible); Move to the right out of Ll_first.setanimation (Animationutils.makeoutanimation (this, true)); Move to the right into ll_second.setanimation (Animationutils.makeinanimation (this, true)); Ll_first.setvisibility (view.visible); Ll_second.setvisibility (view.gone); Move left into ll_first.setanimation (Animationutils.makeinanimation (this, false)); Move to the left ll_second.setanimation (Animationutils.makeoutanimation (this, false));
Second, add animation with Translateanimation
First write a Animationutil tool class: This provides only the top and bottom movement effect
public class Animationutil {private static final String TAG = Animationutil.class . Getsimplename (); /** * Moves from the control's location to the bottom of the control * * @return */public static translateanimation Movetoviewbottom () {Trans Lateanimation mhiddenaction = new Translateanimation (animation.relative_to_self, 0.0f, animation.relative_t O_self, 0.0f, Animation.relative_to_self, 0.0f, Animation.relative_to_self, 1.0f); Mhiddenaction.setduration (500); return mhiddenaction; /** * Move from the bottom of the control to the location of the control * * @return */public static translateanimation Movetoviewlocation () { Translateanimation mhiddenaction = new Translateanimation (animation.relative_to_self, 0.0f, Animation.REL Ative_to_self, 0.0f, Animation.relative_to_self, 1.0f, Animation.relative_to_self, 0.0f); Mhiddenaction.setduration (500); return mhiddenaction; }}
You can set the animation when you hide it.
Ll_first.setvisibility (view.gone); Ll_second.setvisibility (view.visible); Ll_first.setanimation (Animationutil.movetoviewbottom ()); Ll_second.setanimation (Animationutil.movetoviewlocation ());
Blog Original address: http://www.cnblogs.com/liqw/p/4602876.html
Android control display hide up and down move animation around