import android.os.handler;import android.view.view;import android.view.animation.animation; import android.view.animation.translateanimation;public class animationutil {/** * move from the control's location to the bottom of the control * * @return */public static TranslateAnimation Movetoviewbottom () {translateanimation mhiddenaction = new translateanimation ( Animation.relative_to_self, 0.0f,animation.relative_to_self, 0.0f, animation.relative_to_self, 0.0f, animation.relative_to_self, 1.0f); mhiddenaction.setduration (+);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.relative_to_self, 0.0f, animation.relative_to_self, 1.0f, animation.relative_to_self, 0.0f); mhiddenaction.setduration (+); return mhiddenaction;} Public static void showview (View view) {view.setvisibility (view.visible); View.setAnimation ( Animationutil.movetoviewlocation ());} Public static void hideview (Final view view) {view.setanimation ( Animationutil.movetoviewbottom ()); New handler (). postdelayed (New runnable () {@Overridepublic void run () {view.setvisibility (view.gone);}}, 1000);}}
Android controls hide and show animations