Java Code Examples for android.view.animation.AnimationSet#setInterpolator()

The following examples show how to use android.view.animation.AnimationSet#setInterpolator() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may want to check out the right sidebar which shows the related API usage.
Example 1
public static AnimationSet startAlphaHideAnimation(final View VIEW) {
	final int ANIMATION_DURATION = 350;

	final Animation mHideViewAnimation = new AlphaAnimation(1f, 0f);

	AnimationSet mAnimations = new AnimationSet(true);
	mAnimations.setDuration(ANIMATION_DURATION);
	mAnimations.setInterpolator(new AccelerateDecelerateInterpolator());
	mAnimations.addAnimation(mHideViewAnimation);
	mAnimations.setFillAfter(true);

       if(VIEW != null)
	    VIEW.startAnimation(mAnimations);

	return mAnimations;
}
 
Example 2
private void startShowContinueIconAnimations() {
    Animation mScaleAnimation = new ScaleAnimation(0, 1, 0, 1, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
    Animation mRotateAnimation = new RotateAnimation(
            0, 360,
            Animation.RELATIVE_TO_SELF, 0.5f,
            Animation.RELATIVE_TO_SELF, 0.5f
    );
    mRotateAnimation.setRepeatCount(0);

    AnimationSet mAnimations = new AnimationSet(true);
    mAnimations.setDuration(REVEAL_ANIMATION_DURATION);
    mAnimations.setFillAfter(true);
    mAnimations.setInterpolator(new OvershootInterpolator(1.5f));
    mAnimations.addAnimation(mScaleAnimation);
    mAnimations.addAnimation(mRotateAnimation);

    mContinueIcon.startAnimation(mAnimations);
}
 
Example 3
/**
 * For the Activity Circle Icon and text
 */

public static void startAlphaRevealAnimation(final View VIEW) {
    final int ANIMATION_DURATION = 1000;

    final Animation mShowViewAnimation = new AlphaAnimation(0f, 1f);
    mShowViewAnimation.setDuration(ANIMATION_DURATION);

    AnimationSet mAnimations = new AnimationSet(true);
    mAnimations.setInterpolator(new AccelerateDecelerateInterpolator());
    mAnimations.addAnimation(mShowViewAnimation);
    mAnimations.setFillAfter(true);

    if (VIEW != null)
        VIEW.startAnimation(mAnimations);

}
 
Example 4
public void display(float x) {
  this.startPositionX = x;
  this.lastPositionX  = x;

  recordButtonFab.setVisibility(View.VISIBLE);

  AnimationSet animation = new AnimationSet(true);
  animation.addAnimation(new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0,
                                                Animation.RELATIVE_TO_SELF, 0,
                                                Animation.RELATIVE_TO_SELF, -.25f,
                                                Animation.RELATIVE_TO_SELF, -.25f));

  animation.addAnimation(new ScaleAnimation(.5f, 1f, .5f, 1f,
                                            Animation.RELATIVE_TO_SELF, .5f,
                                            Animation.RELATIVE_TO_SELF, .5f));

  animation.setFillBefore(true);
  animation.setFillAfter(true);
  animation.setDuration(ANIMATION_DURATION);
  animation.setInterpolator(new OvershootInterpolator());

  recordButtonFab.startAnimation(animation);
}
 
Example 5
private Animation getAnimationSet(boolean fromXML) {
    if (fromXML) {
        Animation animation = AnimationUtils.loadAnimation(this, R.anim.view_animation);
        return animation;
    } else {
        AnimationSet innerAnimationSet = new AnimationSet(true);
        innerAnimationSet.setInterpolator(new BounceInterpolator());
        innerAnimationSet.setStartOffset(1000);
        innerAnimationSet.addAnimation(getScaleAnimation());
        innerAnimationSet.addAnimation(getTranslateAnimation());

        AnimationSet animationSet = new AnimationSet(true);
        animationSet.setInterpolator(new LinearInterpolator());

        animationSet.addAnimation(getAlphaAnimation());
        animationSet.addAnimation(getRotateAnimation());
        animationSet.addAnimation(innerAnimationSet);

        return animationSet;
    }
}
 
Example 6
Source Project: FamilyChat   File: AnimationController.java    License: Apache License 2.0 5 votes vote down vote up
public void slideTranslateOutToTop(View view, long durationMillis, long delayMillis)
{
	TranslateAnimation animation1 = new TranslateAnimation(rela1, 0, rela1, 0, rela1, 0, rela1, -1);
	AnimationSet animation = new AnimationSet(false);
	animation.addAnimation(animation1);
	animation.setInterpolator(new LinearInterpolator());
	baseOut(view, animation, durationMillis, delayMillis);
}
 
Example 7
public void hide(float x) {
  this.lastPositionX = x;

  float offset = getOffset(x);

  AnimationSet animation = new AnimationSet(false);
  Animation scaleAnimation = new ScaleAnimation(1, 0.5f, 1, 0.5f,
                                                Animation.RELATIVE_TO_SELF, 0.5f,
                                                Animation.RELATIVE_TO_SELF, 0.5f);

  Animation translateAnimation = new TranslateAnimation(Animation.ABSOLUTE, offset,
                                                        Animation.ABSOLUTE, 0,
                                                        Animation.RELATIVE_TO_SELF, -.25f,
                                                        Animation.RELATIVE_TO_SELF, -.25f);

  scaleAnimation.setInterpolator(new AnticipateOvershootInterpolator(1.5f));
  translateAnimation.setInterpolator(new DecelerateInterpolator());
  animation.addAnimation(scaleAnimation);
  animation.addAnimation(translateAnimation);
  animation.setDuration(ANIMATION_DURATION);
  animation.setFillBefore(true);
  animation.setFillAfter(false);
  animation.setInterpolator(new AnticipateOvershootInterpolator(1.5f));

  recordButtonFab.setVisibility(View.GONE);
  recordButtonFab.clearAnimation();
  recordButtonFab.startAnimation(animation);
}
 
Example 8
private void hide(float x) {
    this.lastPositionX = x;

    float offset = getOffset(x);
    int widthAdjustment = getWidthAdjustment();

    AnimationSet animation = new AnimationSet(false);
    Animation scaleAnimation = new ScaleAnimation(1, 0.5f, 1, 0.5f,
            Animation.RELATIVE_TO_SELF, 0.5f,
            Animation.RELATIVE_TO_SELF, 0.5f);

    Animation translateAnimation = new TranslateAnimation(Animation.ABSOLUTE, offset + widthAdjustment,
            Animation.ABSOLUTE, widthAdjustment,
            Animation.RELATIVE_TO_SELF, -.25f,
            Animation.RELATIVE_TO_SELF, -.25f);

    scaleAnimation.setInterpolator(new AnticipateOvershootInterpolator(1.5f));
    translateAnimation.setInterpolator(new DecelerateInterpolator());
    animation.addAnimation(scaleAnimation);
    animation.addAnimation(translateAnimation);
    animation.setDuration(ANIMATION_DURATION);
    animation.setFillBefore(true);
    animation.setFillAfter(false);
    animation.setInterpolator(new AnticipateOvershootInterpolator(1.5f));

    recordButtonFab.setVisibility(View.GONE);
    recordButtonFab.clearAnimation();
    recordButtonFab.startAnimation(animation);
}
 
Example 9
private void addTextFadeAnimations(AnimationSet set) {
    AlphaAnimation mFadeInAnim = new AlphaAnimation(1, FADE_MOUNT);
    mFadeInAnim.setDuration(CHARACTER_ANIM_DURATION);
    set.addAnimation(mFadeInAnim);
    AlphaAnimation mFadeOutAnim = new AlphaAnimation(FADE_MOUNT, 1);
    mFadeOutAnim.setDuration(CHARACTER_ANIM_DURATION);
    mFadeOutAnim.setStartOffset(CHARACTER_ANIM_DURATION + 20);
    mFadeOutAnim.setFillAfter(true);
    set.addAnimation(mFadeOutAnim);
    set.setInterpolator(interpolator);
}
 
Example 10
/**
 * For the Card Views
 */
public static void startAlphaRevealAnimation(int delay, final View VIEW, boolean includeTransition) {
    final int ANIMATION_DURATION = 300;

    final Animation mAlphaAnimation = new AlphaAnimation(0f, 1f);
    mAlphaAnimation.setDuration(ANIMATION_DURATION);
    mAlphaAnimation.setFillAfter(true);

    final AnimationSet mRevealAnimations = new AnimationSet(true);
    mRevealAnimations.setInterpolator(new AccelerateDecelerateInterpolator());
    mRevealAnimations.addAnimation(mAlphaAnimation);
    mRevealAnimations.setFillAfter(true);

    if (includeTransition) {
        final Animation mTransitionAnimation = new TranslateAnimation(0, 0, VIEW.getHeight() / 2, 0);
        mTransitionAnimation.setDuration(ANIMATION_DURATION);
        mTransitionAnimation.setFillAfter(false);

        mRevealAnimations.addAnimation(mTransitionAnimation);
    }

    new Handler().postDelayed(() -> {
        if (VIEW != null)
            VIEW.startAnimation(mRevealAnimations);
    }, delay);

}
 
Example 11
Source Project: UltimateAndroid   File: RayMenu.java    License: Apache License 2.0 5 votes vote down vote up
private static Animation createItemDisapperAnimation(final long duration, final boolean isClicked) {
	AnimationSet animationSet = new AnimationSet(true);
	animationSet.addAnimation(new ScaleAnimation(1.0f, isClicked ? 2.0f : 0.0f, 1.0f, isClicked ? 2.0f : 0.0f,
			Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f));
	animationSet.addAnimation(new AlphaAnimation(1.0f, 0.0f));

	animationSet.setDuration(duration);
	animationSet.setInterpolator(new DecelerateInterpolator());
	animationSet.setFillAfter(true);

	return animationSet;
}
 
Example 12
private void animateScaleIn() {
    if (mContentView == null) {
        return;
    }
    ScaleAnimation scaleAnimation = new ScaleAnimation(0.0f, 1.0f, 0.0f, 1.0f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
    AlphaAnimation alpha = new AlphaAnimation(0, 1);
    AnimationSet set = new AnimationSet(true);
    set.addAnimation(scaleAnimation);
    set.addAnimation(alpha);
    set.setInterpolator(new DecelerateInterpolator());
    set.setDuration(mAnimationDuration );
    set.setFillAfter(true);
    mContentView.startAnimation(set);
}
 
Example 13
Source Project: FamilyChat   File: AnimationController.java    License: Apache License 2.0 5 votes vote down vote up
public void slideTranslateOutToBottom(View view, long durationMillis, long delayMillis)
{
	TranslateAnimation animation1 = new TranslateAnimation(rela1, 0, rela1, 0, rela1, 0, rela1,1);
	AnimationSet animation = new AnimationSet(false);
	animation.addAnimation(animation1);
	animation.setInterpolator(new LinearInterpolator());
	baseOut(view, animation, durationMillis, delayMillis);
}
 
Example 14
Source Project: UltimateAndroid   File: ArcMenu.java    License: Apache License 2.0 5 votes vote down vote up
private static Animation createItemDisapperAnimation(final long duration, final boolean isClicked) {
    AnimationSet animationSet = new AnimationSet(true);
    animationSet.addAnimation(new ScaleAnimation(1.0f, isClicked ? 2.0f : 0.0f, 1.0f, isClicked ? 2.0f : 0.0f,
            Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f));
    animationSet.addAnimation(new AlphaAnimation(1.0f, 0.0f));

    animationSet.setDuration(duration);
    animationSet.setInterpolator(new DecelerateInterpolator());
    animationSet.setFillAfter(true);

    return animationSet;
}
 
Example 15
Source Project: timecat   File: ArcMenu.java    License: Apache License 2.0 5 votes vote down vote up
private static Animation createItemDisappearAnimation(final long duration, final boolean isClicked) {
    AnimationSet animationSet = new AnimationSet(true);
    animationSet.addAnimation(new ScaleAnimation(1.0f, isClicked ? 2.0f : 0.0f, 1.0f, isClicked ? 2.0f : 0.0f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f));
    animationSet.addAnimation(new AlphaAnimation(1.0f, 0.0f));

    animationSet.setDuration(duration);
    animationSet.setInterpolator(new DecelerateInterpolator());
    animationSet.setFillAfter(true);

    return animationSet;
}
 
Example 16
Source Project: Dagger2-Sample   File: AnimUtils.java    License: MIT License 5 votes vote down vote up
public static Animation createBgImageInAnimation(int fromX, int toX, int transitionDuration) {
    TranslateAnimation translate = new TranslateAnimation(fromX, toX, 0, 0);
    translate.setDuration(transitionDuration);

    AnimationSet set = new AnimationSet(true);
    set.setInterpolator(new DecelerateInterpolator());
    set.addAnimation(translate);
    return set;
}
 
Example 17
@Override
public Animation hideAnimation() {
    AnimationSet set = new AnimationSet(true);
    Animation alphaAnimation = new AlphaAnimation(1.0f, 0.0f);
    Animation scaleAnimation = new ScaleAnimation(1.0f, 0.1f, 1.0f, 0.1f, Animation.RELATIVE_TO_SELF, 0.5f,
            Animation.RELATIVE_TO_SELF, 0.5f);

    set.setDuration(200);
    set.setInterpolator(new DecelerateInterpolator());
    set.addAnimation(alphaAnimation);
    set.addAnimation(scaleAnimation);
    return set;
}
 
Example 18
/**
 * Hides every currently shown element in the recyclerview. When the last view has been hidden
 * clearNoAnimation() is called
 * @return The time is takes for the last element to hide
 */
public int clear() {
	final int ANIMATION_DURATION = 300;
	final int BASE_DELAY = 50;

	int startPosition = mRecyclerView.getManager().findFirstVisibleItemPosition();
	int endPosition = mRecyclerView.getManager().findLastVisibleItemPosition();

	int timeBeforeLastAnimIsDone = ANIMATION_DURATION;
	for(int i = startPosition; i <= endPosition; i++) {
		int delay = (i - startPosition) * BASE_DELAY;
		final int finalI = i;

		final int TRANSLATE_LENGTH = context.getResources().getDisplayMetrics().heightPixels;
		Animation mTranslateAnim = new TranslateAnimation(0, 0, 0, TRANSLATE_LENGTH);
		Animation mAlphaAnim = new AlphaAnimation(1f, 0f);

		final AnimationSet mAnimSet = new AnimationSet(true);
		mAnimSet.addAnimation(mTranslateAnim);
		mAnimSet.addAnimation(mAlphaAnim);
		mAnimSet.setDuration(ANIMATION_DURATION);
		mAnimSet.setInterpolator(new AccelerateDecelerateInterpolator());
		mAnimSet.setFillAfter(true);
		mAnimSet.setFillBefore(true);

		new Handler().postDelayed(new Runnable() {
			@Override
			public void run() {
				View v = mRecyclerView.getManager().getChildAt(finalI);
				if(v != null) {
					v.startAnimation(mAnimSet);
				}
			}
		}, delay);

		if(i == endPosition) {
			timeBeforeLastAnimIsDone = ANIMATION_DURATION + delay;
		}
	}

	new Handler().postDelayed(new Runnable() {
		@Override
		public void run() {
			clearNoAnimation();
		}
	}, timeBeforeLastAnimIsDone);

	return timeBeforeLastAnimIsDone;
}
 
Example 19
/**
 * Hides every currently shown element in the recyclerview. When the last view has been hidden
 * clearNoAnimation() is called
 *
 * @return The time is takes for the last element to hide
 */
public int clear() {
    final int ANIMATION_DURATION = 300;
    final int BASE_DELAY = 50;

    int startPosition = mRecyclerView.getManager().findFirstVisibleItemPosition();
    int endPosition = mRecyclerView.getManager().findLastVisibleItemPosition();

    int timeBeforeLastAnimIsDone = ANIMATION_DURATION;
    for (int i = startPosition; i <= endPosition; i++) {
        int delay = (i - startPosition) * BASE_DELAY;
        final int finalI = i;

        final int TRANSLATE_LENGTH = context.getResources().getDisplayMetrics().heightPixels;
        Animation mTranslateAnim = new TranslateAnimation(0, 0, 0, TRANSLATE_LENGTH);
        Animation mAlphaAnim = new AlphaAnimation(1f, 0f);

        final AnimationSet mAnimSet = new AnimationSet(true);
        mAnimSet.addAnimation(mTranslateAnim);
        mAnimSet.addAnimation(mAlphaAnim);
        mAnimSet.setDuration(ANIMATION_DURATION);
        mAnimSet.setInterpolator(new AccelerateDecelerateInterpolator());
        mAnimSet.setFillAfter(true);
        mAnimSet.setFillBefore(true);

        new Handler().postDelayed(() -> {
            View v = mRecyclerView.getManager().getChildAt(finalI);
            if (v != null) {
                v.startAnimation(mAnimSet);
            }
        }, delay);

        if (i == endPosition) {
            timeBeforeLastAnimIsDone = ANIMATION_DURATION + delay;
        }
    }

    new Handler().postDelayed(this::clearNoAnimation, timeBeforeLastAnimIsDone);

    return timeBeforeLastAnimIsDone;
}
 
Example 20
Source Project: Hamburger-Button   File: HBButton.java    License: Apache License 2.0 4 votes vote down vote up
private void animateChangeDirection() {

		setClickable(false);
		final float origLeft;
		final float finalLeft;
		final float origRight;
		final float finalRight;
		final float rangeOfLeft;
		final float rangeOfRight;

		if (isSlideLeftToRight()) {

			origRight = mRFSlider.right;
			finalRight = mWidth;

			rangeOfRight = finalRight - origRight;
			rangeOfLeft = rangeOfRight + mWidth / 3;

			mRFSlider.left -= rangeOfRight;
			origLeft = mRFSlider.left;
		} else {
			origLeft = mRFSlider.left;
			finalLeft = 0;

			rangeOfLeft = finalLeft - origLeft;
			rangeOfRight = rangeOfLeft - mWidth / 3;

			mRFSlider.right += -rangeOfLeft;
			origRight = mRFSlider.right;
		}

		Animation animation = new Animation() {
			@Override
			protected void applyTransformation(float interpolatedTime, Transformation t) {
				super.applyTransformation(interpolatedTime, t);
				mRFSlider.set(origLeft + rangeOfLeft * interpolatedTime, mRFSlider.top, origRight + rangeOfRight * interpolatedTime, mRFSlider.bottom);
				invalidate();
			}
		};

		animation.setDuration(getAnimationDuration() / 2);

		AnimationSet animationSet = new AnimationSet(true);
		animationSet.addAnimation(animation);
		animationSet.setInterpolator(new AccelerateDecelerateInterpolator());

		Animation animationLineTop1;
		Animation animationLineCenter1;
		Animation animationLineBottom1;

		Animation animationLineTop2;
		Animation animationLineCenter2;
		Animation animationLineBottom2;

		if (isSlideLeftToRight()) {
			animationLineTop1 = generateLineBackLTRStep1(mLineTop);
			animationLineCenter1 = generateLineBackLTRStep1(mLineCenter);
			animationLineBottom1 = generateLineBackLTRStep1(mLineBottom);

			animationLineTop2 = generateLineBackLTRStep2(mLineTop);
			animationLineCenter2 = generateLineBackLTRStep2(mLineCenter);
			animationLineBottom2 = generateLineBackLTRStep2(mLineBottom);
		} else {
			animationLineTop1 = generateLineBackRTLStep1(mLineTop);
			animationLineCenter1 = generateLineBackRTLStep1(mLineCenter);
			animationLineBottom1 = generateLineBackRTLStep1(mLineBottom);

			animationLineTop2 = generateLineBackRTLStep2(mLineTop);
			animationLineCenter2 = generateLineBackRTLStep2(mLineCenter);
			animationLineBottom2 = generateLineBackRTLStep2(mLineBottom);
		}

		animationSet.addAnimation(animationLineTop1);
		animationSet.addAnimation(animationLineCenter1);
		animationSet.addAnimation(animationLineBottom1);

		animationSet.addAnimation(animationLineTop2);
		animationSet.addAnimation(animationLineCenter2);
		animationSet.addAnimation(animationLineBottom2);

		animationSet.setAnimationListener(directionChangeListener);

		startAnimation(animationSet);
	}