Search in sources :

Example 16 with TranslateAnimation

use of android.view.animation.TranslateAnimation in project KJFrameForAndroid by kymjs.

the class KJScrollView method boundBack.

/**
     * 将内容布局移动到原位置 可以在UP事件中调用, 也可以在其他需要的地方调用, 如手指移动到当前ScrollView外时
     */
private void boundBack() {
    if (!isMoved) {
        // 如果没有移动布局, 则跳过执行
        return;
    }
    // 开启动画
    TranslateAnimation anim = new TranslateAnimation(0, 0, contentView.getTop(), originalRect.top);
    anim.setDuration(ANIM_TIME);
    contentView.startAnimation(anim);
    // 设置回到正常的布局位置
    contentView.layout(originalRect.left, originalRect.top, originalRect.right, originalRect.bottom);
    // 将标志位设回false
    canPullDown = false;
    canPullUp = false;
    isMoved = false;
}
Also used : TranslateAnimation(android.view.animation.TranslateAnimation)

Example 17 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)

Example 18 with TranslateAnimation

use of android.view.animation.TranslateAnimation in project Crouton by keyboardsurfer.

the class DefaultAnimationsBuilder method buildDefaultSlideInDownAnimation.

/**
   * @param croutonView
   *   The croutonView which gets animated.
   *
   * @return The default Animation for a showing {@link Crouton}.
   */
static Animation buildDefaultSlideInDownAnimation(View croutonView) {
    if (!areLastMeasuredInAnimationHeightAndCurrentEqual(croutonView) || (null == slideInDownAnimation)) {
        slideInDownAnimation = new TranslateAnimation(// X: from, to
        0, // X: from, to
        0, // Y: from, to
        -croutonView.getMeasuredHeight(), // Y: from, to
        0);
        slideInDownAnimation.setDuration(DURATION);
        setLastInAnimationHeight(croutonView.getMeasuredHeight());
    }
    return slideInDownAnimation;
}
Also used : TranslateAnimation(android.view.animation.TranslateAnimation)

Example 19 with TranslateAnimation

use of android.view.animation.TranslateAnimation in project Crouton by keyboardsurfer.

the class DefaultAnimationsBuilder method buildDefaultSlideOutUpAnimation.

/**
   * @param croutonView
   *   The croutonView which gets animated.
   *
   * @return The default Animation for a hiding {@link Crouton}.
   */
static Animation buildDefaultSlideOutUpAnimation(View croutonView) {
    if (!areLastMeasuredOutAnimationHeightAndCurrentEqual(croutonView) || (null == slideOutUpAnimation)) {
        slideOutUpAnimation = new TranslateAnimation(// X: from, to
        0, // X: from, to
        0, // Y: from, to
        0, // Y: from, to
        -croutonView.getMeasuredHeight());
        slideOutUpAnimation.setDuration(DURATION);
        setLastOutAnimationHeight(croutonView.getMeasuredHeight());
    }
    return slideOutUpAnimation;
}
Also used : TranslateAnimation(android.view.animation.TranslateAnimation)

Example 20 with TranslateAnimation

use of android.view.animation.TranslateAnimation in project nmid-headline by miao1007.

the class PlatformListPage method initAnim.

private void initAnim() {
    animShow = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, 1, Animation.RELATIVE_TO_SELF, 0);
    animShow.setDuration(300);
    animHide = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, 1);
    animHide.setDuration(300);
}
Also used : TranslateAnimation(android.view.animation.TranslateAnimation)

Aggregations

TranslateAnimation (android.view.animation.TranslateAnimation)156 Animation (android.view.animation.Animation)69 AlphaAnimation (android.view.animation.AlphaAnimation)65 AnimationSet (android.view.animation.AnimationSet)48 ScaleAnimation (android.view.animation.ScaleAnimation)27 View (android.view.View)17 AnimationListener (android.view.animation.Animation.AnimationListener)16 AccelerateDecelerateInterpolator (android.view.animation.AccelerateDecelerateInterpolator)14 AccelerateInterpolator (android.view.animation.AccelerateInterpolator)14 ClipRectAnimation (android.view.animation.ClipRectAnimation)12 LinearInterpolator (android.view.animation.LinearInterpolator)12 CurvedTranslateAnimation (com.android.server.wm.animation.CurvedTranslateAnimation)12 DecelerateInterpolator (android.view.animation.DecelerateInterpolator)11 ListView (android.widget.ListView)11 TextView (android.widget.TextView)11 ImageView (android.widget.ImageView)9 WindowAnimation_activityCloseEnterAnimation (com.android.internal.R.styleable.WindowAnimation_activityCloseEnterAnimation)8 WindowAnimation_activityCloseExitAnimation (com.android.internal.R.styleable.WindowAnimation_activityCloseExitAnimation)8 WindowAnimation_activityOpenEnterAnimation (com.android.internal.R.styleable.WindowAnimation_activityOpenEnterAnimation)8 WindowAnimation_activityOpenExitAnimation (com.android.internal.R.styleable.WindowAnimation_activityOpenExitAnimation)8