1. 程式人生 > >刪除listview中itme的動畫效果

刪除listview中itme的動畫效果

這是一個非常簡答的退出進入效果,直接呼叫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); }