Search in sources :

Example 66 with TranslateAnimation

use of android.view.animation.TranslateAnimation in project caronae-android by caronae.

the class Util method expandOrCollapse.

public static void expandOrCollapse(final View v, boolean expand) {
    TranslateAnimation anim;
    if (expand) {
        anim = new TranslateAnimation(0.0f, 0.0f, -v.getHeight(), 0.0f);
        v.setVisibility(View.VISIBLE);
    } else {
        anim = new TranslateAnimation(0.0f, 0.0f, 0.0f, -v.getHeight());
        Animation.AnimationListener collapselistener = new Animation.AnimationListener() {

            @Override
            public void onAnimationStart(Animation animation) {
            }

            @Override
            public void onAnimationRepeat(Animation animation) {
            }

            @Override
            public void onAnimationEnd(Animation animation) {
                v.setVisibility(View.GONE);
            }
        };
        anim.setAnimationListener(collapselistener);
    }
    anim.setDuration(300);
    anim.setInterpolator(new AccelerateInterpolator(0.5f));
    v.startAnimation(anim);
}
Also used : AccelerateInterpolator(android.view.animation.AccelerateInterpolator) TranslateAnimation(android.view.animation.TranslateAnimation) TranslateAnimation(android.view.animation.TranslateAnimation) Animation(android.view.animation.Animation)

Example 67 with TranslateAnimation

use of android.view.animation.TranslateAnimation in project FlycoDialog_Master by H07000223.

the class NormalListDialog method init.

private void init() {
    widthScale(0.8f);
    /**
     * LayoutAnimation
     */
    TranslateAnimation animation = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 2f, Animation.RELATIVE_TO_SELF, 0f, Animation.RELATIVE_TO_SELF, 0f, Animation.RELATIVE_TO_SELF, 0);
    animation.setInterpolator(new DecelerateInterpolator());
    animation.setDuration(550);
    mLac = new LayoutAnimationController(animation, 0.12f);
    mLac.setInterpolator(new DecelerateInterpolator());
}
Also used : DecelerateInterpolator(android.view.animation.DecelerateInterpolator) LayoutAnimationController(android.view.animation.LayoutAnimationController) TranslateAnimation(android.view.animation.TranslateAnimation)

Example 68 with TranslateAnimation

use of android.view.animation.TranslateAnimation in project FlycoDialog_Master by H07000223.

the class ActionSheetDialog method init.

private void init() {
    widthScale(0.95f);
    /**
     * LayoutAnimation
     */
    TranslateAnimation animation = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0f, Animation.RELATIVE_TO_SELF, 0f, Animation.RELATIVE_TO_SELF, 6f, Animation.RELATIVE_TO_SELF, 0);
    animation.setInterpolator(new DecelerateInterpolator());
    animation.setDuration(350);
    animation.setStartOffset(150);
    mLac = new LayoutAnimationController(animation, 0.12f);
    mLac.setInterpolator(new DecelerateInterpolator());
}
Also used : DecelerateInterpolator(android.view.animation.DecelerateInterpolator) LayoutAnimationController(android.view.animation.LayoutAnimationController) TranslateAnimation(android.view.animation.TranslateAnimation)

Example 69 with TranslateAnimation

use of android.view.animation.TranslateAnimation in project SnackBar by MrEngineer13.

the class SnackContainer method init.

private void init() {
    mInAnimationSet = new AnimationSet(false);
    TranslateAnimation mSlideInAnimation = new TranslateAnimation(TranslateAnimation.RELATIVE_TO_PARENT, 0.0f, TranslateAnimation.RELATIVE_TO_PARENT, 0.0f, TranslateAnimation.RELATIVE_TO_SELF, 1.0f, TranslateAnimation.RELATIVE_TO_SELF, 0.0f);
    AlphaAnimation mFadeInAnimation = new AlphaAnimation(0.0f, 1.0f);
    mInAnimationSet.addAnimation(mSlideInAnimation);
    mInAnimationSet.addAnimation(mFadeInAnimation);
    mOutAnimationSet = new AnimationSet(false);
    TranslateAnimation mSlideOutAnimation = new TranslateAnimation(TranslateAnimation.RELATIVE_TO_PARENT, 0.0f, TranslateAnimation.RELATIVE_TO_PARENT, 0.0f, TranslateAnimation.RELATIVE_TO_SELF, 0.0f, TranslateAnimation.RELATIVE_TO_SELF, 1.0f);
    AlphaAnimation mFadeOutAnimation = new AlphaAnimation(1.0f, 0.0f);
    mOutAnimationSet.addAnimation(mSlideOutAnimation);
    mOutAnimationSet.addAnimation(mFadeOutAnimation);
    mOutAnimationSet.setDuration(ANIMATION_DURATION);
    mOutAnimationSet.setAnimationListener(new Animation.AnimationListener() {

        @Override
        public void onAnimationStart(Animation animation) {
        }

        @Override
        public void onAnimationEnd(Animation animation) {
            removeAllViews();
            if (!mSnacks.isEmpty()) {
                sendOnHide(mSnacks.poll());
            }
            if (!isEmpty()) {
                showSnack(mSnacks.peek());
            } else {
                setVisibility(View.GONE);
            }
        }

        @Override
        public void onAnimationRepeat(Animation animation) {
        }
    });
}
Also used : TranslateAnimation(android.view.animation.TranslateAnimation) TranslateAnimation(android.view.animation.TranslateAnimation) AlphaAnimation(android.view.animation.AlphaAnimation) Animation(android.view.animation.Animation) AnimationSet(android.view.animation.AnimationSet) AlphaAnimation(android.view.animation.AlphaAnimation)

Example 70 with TranslateAnimation

use of android.view.animation.TranslateAnimation in project Lazy by l123456789jy.

the class ViewAnimationUtils method translate.

/*
	 *  ************************************************************* 视图移动动画
	 * ********************************************************************
	 */
/**
 * 视图移动
 *
 * @param view           要移动的视图
 * @param fromXDelta     X轴开始坐标
 * @param toXDelta       X轴结束坐标
 * @param fromYDelta     Y轴开始坐标
 * @param toYDelta       Y轴结束坐标
 * @param cycles         重复
 * @param durationMillis 持续时间
 * @param isBanClick     在执行动画的过程中是否禁止点击
 */
public static void translate(final View view, float fromXDelta, float toXDelta, float fromYDelta, float toYDelta, float cycles, long durationMillis, final boolean isBanClick) {
    TranslateAnimation translateAnimation = new TranslateAnimation(fromXDelta, toXDelta, fromYDelta, toYDelta);
    translateAnimation.setDuration(durationMillis);
    if (cycles > 0.0) {
        translateAnimation.setInterpolator(new CycleInterpolator(cycles));
    }
    translateAnimation.setAnimationListener(new AnimationListener() {

        @Override
        public void onAnimationStart(Animation animation) {
            if (isBanClick) {
                view.setClickable(false);
            }
        }

        @Override
        public void onAnimationRepeat(Animation animation) {
        }

        @Override
        public void onAnimationEnd(Animation animation) {
            if (isBanClick) {
                view.setClickable(true);
            }
        }
    });
    view.startAnimation(translateAnimation);
}
Also used : TranslateAnimation(android.view.animation.TranslateAnimation) TranslateAnimation(android.view.animation.TranslateAnimation) AlphaAnimation(android.view.animation.AlphaAnimation) Animation(android.view.animation.Animation) CycleInterpolator(android.view.animation.CycleInterpolator) AnimationListener(android.view.animation.Animation.AnimationListener)

Aggregations

TranslateAnimation (android.view.animation.TranslateAnimation)229 Animation (android.view.animation.Animation)109 AlphaAnimation (android.view.animation.AlphaAnimation)90 AnimationSet (android.view.animation.AnimationSet)69 ScaleAnimation (android.view.animation.ScaleAnimation)44 AccelerateInterpolator (android.view.animation.AccelerateInterpolator)30 AccelerateDecelerateInterpolator (android.view.animation.AccelerateDecelerateInterpolator)27 View (android.view.View)22 DecelerateInterpolator (android.view.animation.DecelerateInterpolator)22 TextView (android.widget.TextView)18 AnimationListener (android.view.animation.Animation.AnimationListener)17 LinearInterpolator (android.view.animation.LinearInterpolator)13 RotateAnimation (android.view.animation.RotateAnimation)13 ClipRectAnimation (android.view.animation.ClipRectAnimation)12 ListView (android.widget.ListView)12 CurvedTranslateAnimation (com.android.server.wm.animation.CurvedTranslateAnimation)12 ImageView (android.widget.ImageView)11 LayoutAnimationController (android.view.animation.LayoutAnimationController)8 WindowAnimation_activityCloseEnterAnimation (com.android.internal.R.styleable.WindowAnimation_activityCloseEnterAnimation)8 WindowAnimation_activityCloseExitAnimation (com.android.internal.R.styleable.WindowAnimation_activityCloseExitAnimation)8