Search in sources :

Example 91 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 92 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 93 with TranslateAnimation

use of android.view.animation.TranslateAnimation in project SmartAndroidSource by jaychou2012.

the class PullScrollView method rollBackAnimation.

private void rollBackAnimation() {
    TranslateAnimation tranAnim = new TranslateAnimation(0, 0, Math.abs(mInitTop - mCurrentTop), 0);
    tranAnim.setDuration(200);
    mHeader.startAnimation(tranAnim);
    mHeader.layout(mHeader.getLeft(), mInitTop, mHeader.getRight(), mInitBottom);
    // �����ƶ�����
    TranslateAnimation innerAnim = new TranslateAnimation(0, 0, mContentView.getTop(), mContentRect.top);
    innerAnim.setDuration(200);
    mContentView.startAnimation(innerAnim);
    mContentView.layout(mContentRect.left, mContentRect.top, mContentRect.right, mContentRect.bottom);
    mContentRect.setEmpty();
    // �ص�������
    if (mCurrentTop > mInitTop + TURN_DISTANCE && mOnTurnListener != null) {
        mOnTurnListener.onTurn();
    }
}
Also used : TranslateAnimation(android.view.animation.TranslateAnimation)

Example 94 with TranslateAnimation

use of android.view.animation.TranslateAnimation in project SmartAndroidSource by jaychou2012.

the class DragGridView method animateGap.

protected void animateGap(int target) {
    for (int i = 0; i < getChildCount(); i++) {
        View v = getChildAt(i);
        if (i == dragged)
            continue;
        int newPos = i;
        if (dragged < target && i >= dragged + 1 && i <= target)
            newPos--;
        else if (target < dragged && i >= target && i < dragged)
            newPos++;
        // animate
        int oldPos = i;
        if (newPositions.get(i) != -1)
            oldPos = newPositions.get(i);
        if (oldPos == newPos)
            continue;
        Point oldXY = getCoorFromIndex(oldPos);
        Point newXY = getCoorFromIndex(newPos);
        Point oldOffset = new Point(oldXY.x - v.getLeft(), oldXY.y - v.getTop());
        Point newOffset = new Point(newXY.x - v.getLeft(), newXY.y - v.getTop());
        TranslateAnimation translate = new TranslateAnimation(Animation.ABSOLUTE, oldOffset.x, Animation.ABSOLUTE, newOffset.x, Animation.ABSOLUTE, oldOffset.y, Animation.ABSOLUTE, newOffset.y);
        translate.setDuration(animT);
        translate.setFillEnabled(true);
        translate.setFillAfter(true);
        v.clearAnimation();
        v.startAnimation(translate);
        newPositions.set(i, newPos);
    }
}
Also used : TranslateAnimation(android.view.animation.TranslateAnimation) Point(android.graphics.Point) ImageView(android.widget.ImageView) View(android.view.View) Point(android.graphics.Point)

Example 95 with TranslateAnimation

use of android.view.animation.TranslateAnimation in project Tapad by berict.

the class AnimateHelper method slideIn.

// Slide Animations
public void slideIn(final View view, final int delay, final long duration, String handlerName) {
    final TranslateAnimation slideIn = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, -1, Animation.RELATIVE_TO_SELF, 0);
    view.setVisibility(View.INVISIBLE);
    slideIn.setInterpolator(new DecelerateInterpolator());
    Map<String, Handler> handlerCreator = new HashMap<>();
    handlerCreator.put(handlerName, new Handler());
    handlerCreator.get(handlerName).postDelayed(new Runnable() {

        @Override
        public void run() {
            view.setVisibility(View.VISIBLE);
            slideIn.setDuration(duration);
            view.startAnimation(slideIn);
            Log.i(TAG, "slide IN effect for " + String.valueOf(duration) + "ms with " + String.valueOf(delay) + "ms delay");
        }
    }, delay);
}
Also used : AccelerateDecelerateInterpolator(android.view.animation.AccelerateDecelerateInterpolator) DecelerateInterpolator(android.view.animation.DecelerateInterpolator) HashMap(java.util.HashMap) TranslateAnimation(android.view.animation.TranslateAnimation) Handler(android.os.Handler)

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