android.view.animation.AnimationSet#setInterpolator()源码实例Demo

下面列出了android.view.animation.AnimationSet#setInterpolator() 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

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;
}
 
源代码2 项目: Twire   文件: WelcomeActivity.java
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);
}
 
源代码3 项目: Twire   文件: AnimationService.java
/**
 * 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);

}
 
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);
}
 
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;
    }
}
 
源代码6 项目: FamilyChat   文件: AnimationController.java
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);
}
 
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);
}
 
源代码8 项目: bcm-android   文件: VoiceRecodingPanel.java
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);
}
 
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);
}
 
源代码10 项目: Twire   文件: AnimationService.java
/**
 * 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);

}
 
源代码11 项目: UltimateAndroid   文件: RayMenu.java
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;
}
 
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);
}
 
源代码13 项目: FamilyChat   文件: AnimationController.java
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);
}
 
源代码14 项目: UltimateAndroid   文件: ArcMenu.java
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;
}
 
源代码15 项目: timecat   文件: ArcMenu.java
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;
}
 
源代码16 项目: Dagger2-Sample   文件: AnimUtils.java
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;
}
 
源代码17 项目: stateLayout   文件: FadeScaleViewAnimProvider.java
@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;
}
 
/**
 * 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;
}
 
源代码19 项目: Twire   文件: MainActivityAdapter.java
/**
 * 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;
}
 
源代码20 项目: Hamburger-Button   文件: HBButton.java
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);
	}