这是一个非常简答的退出进入效果,直接调用ScrollPattern函数AddOrDelete为0表示删除动画效果,为1表示进入动画效果。
这是最简单的一种,因为之前用这方便比较少,所以记录一下,有空再回来完善。
private void ScrollPattern(final View view, final int AddOrDelete) { Animation.AnimationListener al = new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { } @Override public void onAnimationRepeat(Animation animation) { } }; if(AddOrDelete == 0 || AddOrDelete == 2) collapse(view, al); else if(AddOrDelete == 1) AddPattern(view,al); } private void collapse(final View view, Animation.AnimationListener al) { // final int originHeight = view.getMeasuredHeight(); final int originWidth = view.getMeasuredWidth(); Log.i("CLOSEoriginWidth", originWidth + ""); Animation animation = new Animation() { @Override protected void applyTransformation(float interpolatedTime, Transformation t) { if (interpolatedTime == 1.0f) { view.setVisibility(View.GONE); } else { // view.getLayoutParams().height = originHeight - (int) (originHeight * interpolatedTime); view.getLayoutParams().width = originWidth - (int) (originWidth * interpolatedTime); view.requestLayout(); } } @Override public boolean willChangeBounds() { return true; } }; if (al != null) { animation.setAnimationListener(al); } animation.setDuration(1000); view.startAnimation(animation); } private void AddPattern(final View view,Animation.AnimationListener al) { // final int originHeight = view.getMeasuredHeight(); final int originWidth = view.getMeasuredWidth(); Log.i("ADDoriginWidth",originWidth+""); view.setVisibility(View.VISIBLE); Animation animation = new Animation() { @Override protected void applyTransformation(float interpolatedTime, Transformation t) { if (interpolatedTime == 1.0f) { view.setVisibility(View.VISIBLE); } else { // view.getLayoutParams().height = originHeight - (int) (originHeight * interpolatedTime); view.getLayoutParams().width = (int) (720 * interpolatedTime); view.requestLayout(); } } @Override public boolean willChangeBounds() { return true; } }; if (al != null) { animation.setAnimationListener(al); } animation.setDuration(3000); view.startAnimation(animation); }