您好,登錄后才能下訂單哦!
import android.os.Handler; import android.view.View; import android.view.animation.Animation; import android.view.animation.TranslateAnimation; public class AnimationUtil { /** * 從控件所在位置移動到控件的底部 * * @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(1000); return mHiddenAction; } /** * 從控件的底部移動到控件所在位置 * * @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(1000); 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() { @Override public void run() { view.setVisibility(View.GONE); } }, 1000); } }
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。