安卓控件隐藏和显示动画
importandroid.os.Handler;importandroid.view.View;importandroid.view.animation.Animation;importandroid.view.animation.TranslateAnimation;publicclassAnimationUtil{/***从控件所在位置移动到控件的底部**@return*/publicstaticTranslateAnimationmoveToViewBottom(){TranslateAnimationmHiddenAction=newTranslateAnimation(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(1000);returnmHiddenAction;}/***从控件的底部移动到控件所在位置**@return*/publicstaticTranslateAnimationmoveToViewLocation(){TranslateAnimationmHiddenAction=newTranslateAnimation(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(1000);returnmHiddenAction;}publicstaticvoidshowView(Viewview){view.setVisibility(View.VISIBLE);view.setAnimation(AnimationUtil.moveToViewLocation());}publicstaticvoidhideView(finalViewview){view.setAnimation(AnimationUtil.moveToViewBottom());newHandler().postDelayed(newRunnable(){@Overridepublicvoidrun(){view.setVisibility(View.GONE);}},1000);}}
声明:本站所有文章资源内容,如无特殊说明或标注,均为采集网络资源。如若本站内容侵犯了原著者的合法权益,可联系本站删除。