Android control display hide up and down move animation around

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.