Search in sources :

Example 6 with Animation

use of android.view.animation.Animation in project UltimateAndroid by cymcsg.

the class UiUtils method collapseViews.

/**
     * Collapse a view which has already expanded
     *
     * @param v
     */
public static void collapseViews(final View v) {
    final int initialHeight = v.getMeasuredHeight();
    Animation a = new Animation() {

        @Override
        protected void applyTransformation(float interpolatedTime, Transformation t) {
            if (interpolatedTime == 1) {
                v.setVisibility(View.GONE);
            } else {
                v.getLayoutParams().height = initialHeight - (int) (initialHeight * interpolatedTime);
                v.requestLayout();
            }
        }

        @Override
        public boolean willChangeBounds() {
            return true;
        }
    };
    // 1dp/ms
    a.setDuration((int) (initialHeight / v.getContext().getResources().getDisplayMetrics().density) * 1);
    v.startAnimation(a);
}
Also used : Transformation(android.view.animation.Transformation) Animation(android.view.animation.Animation)

Example 7 with Animation

use of android.view.animation.Animation in project SimplifyReader by chentao0707.

the class PluginPayTip method show.

public void show() {
    mContainerView.setVisibility(View.VISIBLE);
    Animation animation = AnimationUtils.loadAnimation(mActivity, R.anim.paytip_right_in);
    mPayTipLayout.startAnimation(animation);
}
Also used : Animation(android.view.animation.Animation)

Example 8 with Animation

use of android.view.animation.Animation in project Meizhi by drakeet.

the class AnimRecyclerViewAdapter method showItemAnim.

public void showItemAnim(final View view, final int position) {
    Context context = view.getContext();
    if (position > mLastPosition) {
        view.setAlpha(0);
        view.postDelayed(() -> {
            Animation animation = AnimationUtils.loadAnimation(context, R.anim.slide_in_right);
            animation.setAnimationListener(new Animation.AnimationListener() {

                @Override
                public void onAnimationStart(Animation animation) {
                    view.setAlpha(1);
                }

                @Override
                public void onAnimationEnd(Animation animation) {
                }

                @Override
                public void onAnimationRepeat(Animation animation) {
                }
            });
            view.startAnimation(animation);
        }, DELAY * position);
        mLastPosition = position;
    }
}
Also used : Context(android.content.Context) Animation(android.view.animation.Animation)

Example 9 with Animation

use of android.view.animation.Animation in project Meizhi by drakeet.

the class ScrollAwareFABBehavior method animateIn.

// Same animation that FloatingActionButton.Behavior uses to show the FAB when the AppBarLayout enters
private void animateIn(FloatingActionButton button) {
    button.setVisibility(View.VISIBLE);
    if (Build.VERSION.SDK_INT >= 14) {
        ViewCompat.animate(button).scaleX(1.0F).scaleY(1.0F).alpha(1.0F).setInterpolator(INTERPOLATOR).withLayer().setListener(null).start();
    } else {
        Animation anim = AnimationUtils.loadAnimation(button.getContext(), android.support.design.R.anim.design_fab_in);
        anim.setDuration(200L);
        anim.setInterpolator(INTERPOLATOR);
        button.startAnimation(anim);
    }
}
Also used : Animation(android.view.animation.Animation)

Example 10 with Animation

use of android.view.animation.Animation in project Meizhi by drakeet.

the class ScrollAwareFABBehavior method animateOut.

// Same animation that FloatingActionButton.Behavior uses to hide the FAB when the AppBarLayout exits
private void animateOut(final FloatingActionButton button) {
    if (Build.VERSION.SDK_INT >= 14) {
        ViewCompat.animate(button).scaleX(0.0F).scaleY(0.0F).alpha(0.0F).setInterpolator(INTERPOLATOR).withLayer().setListener(new ViewPropertyAnimatorListener() {

            public void onAnimationStart(View view) {
                ScrollAwareFABBehavior.this.mIsAnimatingOut = true;
            }

            public void onAnimationCancel(View view) {
                ScrollAwareFABBehavior.this.mIsAnimatingOut = false;
            }

            public void onAnimationEnd(View view) {
                ScrollAwareFABBehavior.this.mIsAnimatingOut = false;
                view.setVisibility(View.GONE);
            }
        }).start();
    } else {
        Animation anim = AnimationUtils.loadAnimation(button.getContext(), android.support.design.R.anim.design_fab_out);
        anim.setInterpolator(INTERPOLATOR);
        anim.setDuration(200L);
        anim.setAnimationListener(new Animation.AnimationListener() {

            public void onAnimationStart(Animation animation) {
                ScrollAwareFABBehavior.this.mIsAnimatingOut = true;
            }

            public void onAnimationEnd(Animation animation) {
                ScrollAwareFABBehavior.this.mIsAnimatingOut = false;
                button.setVisibility(View.GONE);
            }

            @Override
            public void onAnimationRepeat(final Animation animation) {
            }
        });
        button.startAnimation(anim);
    }
}
Also used : ViewPropertyAnimatorListener(android.support.v4.view.ViewPropertyAnimatorListener) Animation(android.view.animation.Animation) View(android.view.View)

Aggregations

Animation (android.view.animation.Animation)611 AlphaAnimation (android.view.animation.AlphaAnimation)163 TranslateAnimation (android.view.animation.TranslateAnimation)124 ScaleAnimation (android.view.animation.ScaleAnimation)99 AnimationListener (android.view.animation.Animation.AnimationListener)80 AnimationSet (android.view.animation.AnimationSet)71 View (android.view.View)66 Transformation (android.view.animation.Transformation)62 RotateAnimation (android.view.animation.RotateAnimation)43 Point (android.graphics.Point)35 WindowAnimation_activityCloseEnterAnimation (com.android.internal.R.styleable.WindowAnimation_activityCloseEnterAnimation)35 WindowAnimation_activityCloseExitAnimation (com.android.internal.R.styleable.WindowAnimation_activityCloseExitAnimation)35 WindowAnimation_activityOpenEnterAnimation (com.android.internal.R.styleable.WindowAnimation_activityOpenEnterAnimation)35 WindowAnimation_activityOpenExitAnimation (com.android.internal.R.styleable.WindowAnimation_activityOpenExitAnimation)35 WindowAnimation_taskCloseEnterAnimation (com.android.internal.R.styleable.WindowAnimation_taskCloseEnterAnimation)35 WindowAnimation_taskCloseExitAnimation (com.android.internal.R.styleable.WindowAnimation_taskCloseExitAnimation)35 WindowAnimation_taskOpenEnterAnimation (com.android.internal.R.styleable.WindowAnimation_taskOpenEnterAnimation)35 WindowAnimation_taskOpenExitAnimation (com.android.internal.R.styleable.WindowAnimation_taskOpenExitAnimation)35 WindowAnimation_taskToBackEnterAnimation (com.android.internal.R.styleable.WindowAnimation_taskToBackEnterAnimation)35 WindowAnimation_taskToBackExitAnimation (com.android.internal.R.styleable.WindowAnimation_taskToBackExitAnimation)35