android.view.animation.AnimationSet Java Examples

The following examples show how to use android.view.animation.AnimationSet. 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 check out the related API usage on the sidebar.
Example #1
Source File: AnimationHelper.java    From AnimatedPullToRefresh-master with Apache License 2.0 6 votes vote down vote up
/**
 * Start Loop animation on given list of characters
 */
public long applyLoopAnimation(List<TextView> targetList) {
    long duration = (long) (CHARACTER_ANIM_DURATION * 5f);
    for (final TextView target : targetList) {
        AnimationSet set = new AnimationSet(true);
        if (headerLoopAnim == HeaderLoopAnim.ZOOM) {
            addLoopScaleAnimations(duration, set);
        } else if (headerLoopAnim == HeaderLoopAnim.FADE) {
            addLoopFadeAnimations(duration, set);
        }
        target.startAnimation(set);
    }

    // loop anim iteration
    currentLoopIteration = (currentLoopIteration + 1) % headerLoopAnimIteration;
    return (long) ((duration * 2.1f) + 300);
}
 
Example #2
Source File: LoginActivity.java    From Twire with GNU General Public License v3.0 6 votes vote down vote up
private AnimationSet hideAllViews() {
    if (mContinueIcon.getVisibility() == View.VISIBLE) {
        hideContinueIconAnimations();
    }
    int HIDE_VIEW_ANIMATION_DURATION = 550;
    hideViewAnimation(mGearIcon, HIDE_VIEW_ANIMATION_DURATION);
    hideViewAnimation(mLoginTextLineOne, HIDE_VIEW_ANIMATION_DURATION);
    if (mSuccessMessage.getVisibility() != View.INVISIBLE) {
        hideViewAnimation(mSuccessMessage, HIDE_VIEW_ANIMATION_DURATION);
    }

    if (mSuccessIcon.getVisibility() != View.INVISIBLE) {
        hideViewAnimation(mSuccessIcon, HIDE_VIEW_ANIMATION_DURATION);
        hideViewAnimation(mSuccessCircle, HIDE_VIEW_ANIMATION_DURATION);
        hideViewAnimation(mSuccessCircleShadow, HIDE_VIEW_ANIMATION_DURATION);
    }

    return hideViewAnimation(mLoginTextLineTwo, HIDE_VIEW_ANIMATION_DURATION);
}
 
Example #3
Source File: PostFeedActivity.java    From umeng_community_android with MIT License 6 votes vote down vote up
/**
 * 为话题提示VIew绑定动画</br>
 */
private void startAnimationForTopicTipView() {
    int timePiece = 500;
    int repeatCount = 4;
    int startDeny = 50;
    TranslateAnimation translateAnimation = new TranslateAnimation(0, 0, 10, 0);
    translateAnimation.setRepeatMode(Animation.REVERSE);
    // translateAnimation.setStartOffset(startDeny * repeatCount+timePiece);
    translateAnimation.setRepeatCount(Integer.MAX_VALUE);
    translateAnimation.setDuration(timePiece);

    AlphaAnimation alphaAnimationIn = new AlphaAnimation(0, 1.0f);
    alphaAnimationIn.setDuration(timePiece);
    alphaAnimationIn.setStartOffset(startDeny * repeatCount);

    AnimationSet animationSet = new AnimationSet(true);
    animationSet.addAnimation(alphaAnimationIn);
    animationSet.addAnimation(translateAnimation);
    // animationSet.addAnimation(alphaAnimationOut);
    // animationSet.setFillAfter(true);
    mTopicTipView.startAnimation(animationSet);
}
 
Example #4
Source File: BusyIndicator.java    From BusyIndicator with Apache License 2.0 6 votes vote down vote up
private void calculateProgress(float value) {
    if (value > 0){
        if (value >= maxValue)
            value = maxValue;

        currentValue = value;

        float currentAngle = (360 / maxValue) * value;
        currentAngle += 270;

        float aa = (currentAngle - 270);
        LoaderAngleAnimation angleAnimation = new LoaderAngleAnimation(this, aa);
        angleAnimation.setDuration(300);

        LoaderTextAnimation textAnimation = new LoaderTextAnimation(this);
        textAnimation.setDuration(300);

        AnimationSet animationSet = new AnimationSet(false);
        animationSet.addAnimation(angleAnimation);
        animationSet.addAnimation(textAnimation);
        this.startAnimation(animationSet);
    }
}
 
Example #5
Source File: LoginActivity.java    From Pocket-Plays-for-Twitch with GNU General Public License v3.0 6 votes vote down vote up
private AnimationSet showSuccessAnimation() {
	Log.d(LOG_TAG, "Showing Success Animation");
	mSuccessMessage.setText(
		getResources().getString(R.string.login_on_success_message, new Settings(getBaseContext()).getGeneralTwitchDisplayName())
	);
	final AnimationSet mCircleShadowAnimations = getSuccessShadowAnimation();
	final AnimationSet mCircleAnimations = getSuccessCircleAnimation();
	final AnimationSet mIconAnimations = getSuccessIconAnimation();


	new Handler().postDelayed(new Runnable() {
		@Override
		public void run() {
			mSuccessCircleShadow.startAnimation(mCircleShadowAnimations);
			mSuccessIcon.startAnimation(mIconAnimations);
			showTextLineAnimations(mSuccessMessage, 1);
		}
	}, 150);
	mSuccessCircle.startAnimation(mCircleAnimations);
	hideContinueIconAnimations();
	hideViewAnimation(mLoginTextContainer, HIDE_INSTRUCTIONS_DURATION);

	return mCircleAnimations;
}
 
Example #6
Source File: Reveal.java    From mobile-sdk-android with Apache License 2.0 6 votes vote down vote up
private void setOutAnimation(float[] direction, Interpolator interpolator, long duration) {
    Animation push = new TranslateAnimation(
            Animation.RELATIVE_TO_PARENT, direction[0], Animation.RELATIVE_TO_PARENT, direction[1],
            Animation.RELATIVE_TO_PARENT, direction[2], Animation.RELATIVE_TO_PARENT, direction[3]
    );
    push.setInterpolator(interpolator);
    push.setDuration(duration);

    Animation fade = new AlphaAnimation(1, 0);
    fade.setDuration(duration);
    fade.setInterpolator(interpolator);

    AnimationSet set = new AnimationSet(false);
    set.addAnimation(push);
    set.addAnimation(fade);

    outAnimation = set;
}
 
Example #7
Source File: AnimationUtils.java    From Lay-s with MIT License 6 votes vote down vote up
public static void shakeCurtain(View v) {
    AnimationSet set = new AnimationSet(false);
    Animation anim1 = getTranslateAnimation(0, 0, 0, -200, 110);
    Animation anim2 = getTranslateAnimation(0, 0, -200, 0, 80);
    Animation anim3 = getTranslateAnimation(0, 0, 0, -50, 25);
    Animation anim4 = getTranslateAnimation(0, 0, -50, 0, 25);
    anim1.setStartOffset(20);
    anim2.setStartOffset(230);
    anim3.setStartOffset(360);
    anim4.setStartOffset(400);
    set.addAnimation(anim1);
    set.addAnimation(anim2);
    set.addAnimation(anim3);
    set.addAnimation(anim4);
    v.startAnimation(set);
}
 
Example #8
Source File: WelcomeActivity.java    From Pocket-Plays-for-Twitch with GNU General Public License v3.0 6 votes vote down vote up
private AnimationSet 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);
	return mAnimations;
}
 
Example #9
Source File: AnimationService.java    From Twire with GNU General Public License v3.0 6 votes vote down vote up
public static void setAdapterInsertAnimation(final View aCard, int row, int height) {
    final int ANIMATION_DURATION = 650;
    final int BASE_DELAY = 50;

    TranslateAnimation translationAnimation = new TranslateAnimation(0, 0, height, 0);

    AlphaAnimation alphaAnimation = new AlphaAnimation(0f, 1f);

    final AnimationSet animationSet = new AnimationSet(true);
    animationSet.addAnimation(translationAnimation);
    animationSet.addAnimation(alphaAnimation);
    animationSet.setInterpolator(new AccelerateDecelerateInterpolator());
    animationSet.setFillAfter(true);
    animationSet.setFillBefore(true);
    animationSet.setDuration(ANIMATION_DURATION + row * BASE_DELAY);

    aCard.setAnimation(animationSet);
}
 
Example #10
Source File: DynamicRotationGuideView.java    From AndroidStudyDemo with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 中间的View动画播放
 */
private void playCenter() {
    AnimationSet animationSet = new AnimationSet(false);
    ScaleAnimation scaleSmall = new ScaleAnimation(1.0f, 0.6f, 1.0f, 0.6f,Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
    ScaleAnimation scaleBig = new ScaleAnimation(1.0f, 5.0f/3, 1.0f, 5.0f/3,Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
    scaleBig.setDuration(2*1000);
    scaleBig.setInterpolator(interpolator);
    scaleSmall.setDuration(2*1000);
    scaleSmall.setStartOffset(2*1000);
    scaleSmall.setRepeatCount(-1);
    scaleSmall.setFillEnabled(true);
    scaleSmall.setFillAfter(true);
    scaleBig.setStartOffset(2*1000);
    scaleBig.setRepeatCount(-1);
    scaleBig.setFillEnabled(true);
    scaleBig.setFillAfter(true);
    scaleSmall.setInterpolator(interpolator);
    animationSet.addAnimation(scaleBig);
    animationSet.addAnimation(scaleSmall);
    center.startAnimation(animationSet);
}
 
Example #11
Source File: AnimationService.java    From Twire with GNU General Public License v3.0 6 votes vote down vote up
/**
 * 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 #12
Source File: DraggableGridViewPager.java    From UltimateAndroid with Apache License 2.0 6 votes vote down vote up
private void animateDragged() {
	if (mLastDragged >= 0) {
		final View v = getChildAt(mLastDragged);

		final Rect r = new Rect(v.getLeft(), v.getTop(), v.getRight(), v.getBottom());
		r.inset(-r.width() / 20, -r.height() / 20);
		v.measure(MeasureSpec.makeMeasureSpec(r.width(), MeasureSpec.EXACTLY),
				MeasureSpec.makeMeasureSpec(r.height(), MeasureSpec.EXACTLY));
		v.layout(r.left, r.top, r.right, r.bottom);

		AnimationSet animSet = new AnimationSet(true);
		ScaleAnimation scale = new ScaleAnimation(0.9091f, 1, 0.9091f, 1, v.getWidth() / 2, v.getHeight() / 2);
		scale.setDuration(ANIMATION_DURATION);
		AlphaAnimation alpha = new AlphaAnimation(1, .5f);
		alpha.setDuration(ANIMATION_DURATION);

		animSet.addAnimation(scale);
		animSet.addAnimation(alpha);
		animSet.setFillEnabled(true);
		animSet.setFillAfter(true);

		v.clearAnimation();
		v.startAnimation(animSet);
	}
}
 
Example #13
Source File: MicrophoneRecorderView.java    From deltachat-android with GNU General Public License v3.0 6 votes vote down vote up
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 #14
Source File: RayLayout.java    From UltimateAndroid with Apache License 2.0 6 votes vote down vote up
private static Animation createShrinkAnimation(float fromXDelta, float toXDelta, float fromYDelta, float toYDelta,
		long startOffset, long duration, Interpolator interpolator) {
	AnimationSet animationSet = new AnimationSet(false);
	animationSet.setFillAfter(true);

	final long preDuration = duration / 2;
	Animation rotateAnimation = new RotateAnimation(0, 360, Animation.RELATIVE_TO_SELF, 0.5f,
			Animation.RELATIVE_TO_SELF, 0.5f);
	rotateAnimation.setStartOffset(startOffset);
	rotateAnimation.setDuration(preDuration);
	rotateAnimation.setInterpolator(new LinearInterpolator());
	rotateAnimation.setFillAfter(true);

	animationSet.addAnimation(rotateAnimation);

	Animation translateAnimation = new RotateAndTranslateAnimation(0, toXDelta, 0, toYDelta, 360, 720);
	translateAnimation.setStartOffset(startOffset + preDuration);
	translateAnimation.setDuration(duration - preDuration);
	translateAnimation.setInterpolator(interpolator);
	translateAnimation.setFillAfter(true);

	animationSet.addAnimation(translateAnimation);

	return animationSet;
}
 
Example #15
Source File: AboutActivity.java    From AndroidPlusJava with GNU General Public License v3.0 6 votes vote down vote up
private void startAnimation() {
    AnimationSet animationSet = new AnimationSet(true);
    RotateAnimation rotateAnimation = new RotateAnimation(0, 360,
            RotateAnimation.RELATIVE_TO_SELF, 0.5f,
            RotateAnimation.RELATIVE_TO_SELF, 0.5f);

    ScaleAnimation scaleAnimation = new ScaleAnimation(1.5f, 1, 1.5f, 1,
            ScaleAnimation.RELATIVE_TO_SELF, 0.5f,
            ScaleAnimation.RELATIVE_TO_SELF, 0.5f);

    AlphaAnimation alphaAnimation = new AlphaAnimation(0, 1);

    animationSet.addAnimation(rotateAnimation);
    animationSet.addAnimation(scaleAnimation);
    animationSet.addAnimation(alphaAnimation);
    animationSet.setDuration(2000);
    mAboutInfo.startAnimation(animationSet);
}
 
Example #16
Source File: InputPanel.java    From deltachat-android with GNU General Public License v3.0 6 votes vote down vote up
public ListenableFuture<Void> hide(float x) {
  final SettableFuture<Void> future = new SettableFuture<>();
  float offset = getOffset(x);

  AnimationSet animation = new AnimationSet(true);
  animation.addAnimation(new TranslateAnimation(Animation.ABSOLUTE, offset,
                                                Animation.ABSOLUTE, 0,
                                                Animation.RELATIVE_TO_SELF, 0,
                                                Animation.RELATIVE_TO_SELF, 0));
  animation.addAnimation(new AlphaAnimation(1, 0));

  animation.setDuration(MicrophoneRecorderView.ANIMATION_DURATION);
  animation.setFillBefore(true);
  animation.setFillAfter(false);

  slideToCancelView.postDelayed(() -> future.set(null), MicrophoneRecorderView.ANIMATION_DURATION);
  slideToCancelView.setVisibility(View.GONE);
  slideToCancelView.startAnimation(animation);

  return future;
}
 
Example #17
Source File: ExtendBaseView.java    From imsdk-android with MIT License 6 votes vote down vote up
public void startAnimate(int count)
{
    Animation fadeIn = new AlphaAnimation(0.2f, 1f);
    fadeIn.setInterpolator(new DecelerateInterpolator()); //add this
    fadeIn.setDuration(1000);

    Animation fadeOut = new AlphaAnimation(1f, 0.2f);
    fadeOut.setInterpolator(new AccelerateInterpolator()); //and this
    fadeOut.setStartOffset(1000);
    fadeOut.setDuration(1000);

    final AnimationSet animationSet = new AnimationSet(false);
    animationSet.addAnimation(fadeIn);
    animationSet.addAnimation(fadeOut);
    animationSet.setRepeatCount(count);
    animationSet.setRepeatMode(Animation.REVERSE);
    setAnimation(animationSet);
    animationSet.start();
}
 
Example #18
Source File: CommonViewAnimationActivity.java    From Android-Animation-Set with Apache License 2.0 6 votes vote down vote up
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 #19
Source File: HomeScreenActivity.java    From Gazetti_Newspaper_Reader with MIT License 6 votes vote down vote up
private AnimationSet getEntryAnimation(int inAnimationDuration) {
    //In
    AnimationSet 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);
    mSlideInAnimation.setFillAfter(true);

    AlphaAnimation mFadeInAnimation = new AlphaAnimation(0.0f, 1.0f);
    mFadeInAnimation.setFillAfter(true);

    mInAnimationSet.addAnimation(mSlideInAnimation);
    mInAnimationSet.addAnimation(mFadeInAnimation);

    mInAnimationSet.setDuration(inAnimationDuration);

    return mInAnimationSet;

}
 
Example #20
Source File: ArcLayout.java    From timecat with Apache License 2.0 6 votes vote down vote up
/**
 * 收缩动画
 */
private static Animation createShrinkAnimation(float fromXDelta, float toXDelta, float fromYDelta, float toYDelta, long startOffset, long duration, Interpolator interpolator) {
    AnimationSet animationSet = new AnimationSet(false);
    animationSet.setFillAfter(true);
    //收缩过程中,child 逆时针自旋转360度
    final long preDuration = duration / 2;
    Animation rotateAnimation = new RotateAnimation(0, 360, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
    rotateAnimation.setStartOffset(startOffset);
    rotateAnimation.setDuration(preDuration);
    rotateAnimation.setInterpolator(new LinearInterpolator());
    rotateAnimation.setFillAfter(true);

    animationSet.addAnimation(rotateAnimation);
    //收缩过程中位移,并逆时针旋转360度
    Animation translateAnimation = new RotateAndTranslateAnimation(0, toXDelta, 0, toYDelta, 360, 720);
    translateAnimation.setStartOffset(startOffset + preDuration);
    translateAnimation.setDuration(duration - preDuration);
    translateAnimation.setInterpolator(interpolator);
    translateAnimation.setFillAfter(true);

    animationSet.addAnimation(translateAnimation);

    return animationSet;
}
 
Example #21
Source File: Fragment_home.java    From FoodOrdering with Apache License 2.0 6 votes vote down vote up
/**
 * 创建动画 平移动画直接传递偏移量
 *
 * @param startX
 * @param startY
 * @return
 */
private Animation createAnim(int startX, int startY) {
    int[] des = new int[2];
    imgCart.getLocationInWindow(des);
    AnimationSet set = new AnimationSet(false);
    Animation translationX = new TranslateAnimation(0, des[0] - startX, 0, 0);
    translationX.setInterpolator(new LinearInterpolator());
    Animation translationY = new TranslateAnimation(0, 0, 0, des[1] - startY);
    translationY.setInterpolator(new AccelerateInterpolator());
    Animation alpha = new AlphaAnimation(1, 0.5f);
    set.addAnimation(translationX);
    set.addAnimation(translationY);
    set.addAnimation(alpha);
    set.setDuration(500);
    return set;
}
 
Example #22
Source File: Adapter_Foods.java    From FoodOrdering with Apache License 2.0 6 votes vote down vote up
/**
 * 显示减号的动画
 */
private Animation getShowAnimation() {
    AnimationSet set = new AnimationSet(true);
    RotateAnimation rotate = new RotateAnimation(0, 720, RotateAnimation.RELATIVE_TO_SELF, 0.5f, RotateAnimation.RELATIVE_TO_SELF, 0.5f);
    set.addAnimation(rotate);
    TranslateAnimation translate = new TranslateAnimation(
            TranslateAnimation.RELATIVE_TO_SELF, 2f
            , TranslateAnimation.RELATIVE_TO_SELF, 0
            , TranslateAnimation.RELATIVE_TO_SELF, 0
            , TranslateAnimation.RELATIVE_TO_SELF, 0);
    set.addAnimation(translate);
    AlphaAnimation alpha = new AlphaAnimation(0, 1);
    set.addAnimation(alpha);
    set.setDuration(500);
    return set;
}
 
Example #23
Source File: Adapter_Foods.java    From FoodOrdering with Apache License 2.0 6 votes vote down vote up
/**
 * 隐藏减号的动画
 */
private Animation getHiddenAnimation() {
    AnimationSet set = new AnimationSet(true);
    RotateAnimation rotate = new RotateAnimation(0, 720, RotateAnimation.RELATIVE_TO_SELF, 0.5f, RotateAnimation.RELATIVE_TO_SELF, 0.5f);
    set.addAnimation(rotate);
    TranslateAnimation translate = new TranslateAnimation(
            TranslateAnimation.RELATIVE_TO_SELF, 0
            , TranslateAnimation.RELATIVE_TO_SELF, 2f
            , TranslateAnimation.RELATIVE_TO_SELF, 0
            , TranslateAnimation.RELATIVE_TO_SELF, 0);
    set.addAnimation(translate);
    AlphaAnimation alpha = new AlphaAnimation(1, 0);
    set.addAnimation(alpha);
    set.setDuration(500);
    return set;
}
 
Example #24
Source File: MicrophoneRecorderView.java    From mollyim-android with GNU General Public License v3.0 6 votes vote down vote up
void display(float x, float y) {
  this.startPositionX = x;
  this.startPositionY = y;

  recordButtonFab.setVisibility(View.VISIBLE);

  AnimationSet animation = new AnimationSet(true);
  animation.addAnimation(new TranslateAnimation(Animation.ABSOLUTE, 0,
                                                Animation.ABSOLUTE, 0,
                                                Animation.ABSOLUTE, 0,
                                                Animation.ABSOLUTE, 0));

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

  animation.setDuration(ANIMATION_DURATION);
  animation.setInterpolator(new OvershootInterpolator());

  recordButtonFab.startAnimation(animation);
}
 
Example #25
Source File: ViewAnimation.java    From geopackage-mapcache-android with MIT License 6 votes vote down vote up
/**
 * Assign a "scale to 120% and back bounce + fade out and in" animation to the given view
 * @param view the view to animate
 * @param duration duration of the animation
 */
public static void setBounceAnimatiom(View view, long duration){
    ScaleAnimation grow = new ScaleAnimation(1.0f, 1.2f, 1.0f, 1.2f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
    grow.setDuration(duration);
    ScaleAnimation shrink = new ScaleAnimation(1.0f, 0.8f, 1.0f, 0.8f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
    shrink.setDuration(duration);
    shrink.setStartOffset(duration);

    // Fade out then repeat to fade back in
    AlphaAnimation fadeOut = new AlphaAnimation(1.0f, 0.3f);
    fadeOut.setInterpolator(new DecelerateInterpolator()); //and this
    fadeOut.setDuration(100);
    fadeOut.setRepeatMode(Animation.REVERSE);
    fadeOut.setRepeatCount(1);

    AnimationSet set = new AnimationSet(false);
    set.addAnimation(grow);
    set.addAnimation(shrink);
    set.addAnimation(fadeOut);
    view.startAnimation(set);
}
 
Example #26
Source File: BasePopupWindow.java    From FilterTabView with Apache License 2.0 6 votes vote down vote up
/**
 * 进入动画
 *
 * @param context
 * @param fromYDelta
 * @return
 */
private void createInAnimation(Context context, int fromYDelta) {
    try {
        AnimationSet set = new AnimationSet(context, null);
        set.setFillAfter(true);
        TranslateAnimation animation = new TranslateAnimation(0, 0, fromYDelta, 0);
        animation.setDuration(ANIMATION_TIME);
        set.addAnimation(animation);

        if (mFrameLayout != null) {
            mRootView.setAnimation(set);
            AnimationSet setAlpha = new AnimationSet(mContext, null);
            setAlpha.setFillAfter(true);
            AlphaAnimation alphaAnimation = new AlphaAnimation(0f, 1f);
            alphaAnimation.setDuration(ANIMATION_TIME);
            setAlpha.addAnimation(alphaAnimation);
            mFrameLayout.startAnimation(setAlpha);
        } else {
            mRootView.startAnimation(set);
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
Example #27
Source File: RippleImageView.java    From RippleImageView with Apache License 2.0 6 votes vote down vote up
/**
 * 初始化动画集
 * @return
 */
private AnimationSet initAnimationSet() {
    AnimationSet as = new AnimationSet(true);
    //缩放度:变大两倍
    ScaleAnimation sa = new ScaleAnimation(1f, 2f, 1f, 2f,
            ScaleAnimation.RELATIVE_TO_SELF, 0.5f,
            ScaleAnimation.RELATIVE_TO_SELF, 0.5f);
    sa.setDuration(show_spacing_time * 3);
    sa.setRepeatCount(Animation.INFINITE);// 设置循环
    //透明度
    AlphaAnimation aa = new AlphaAnimation(1, 0.1f);
    aa.setDuration(show_spacing_time * 3);
    aa.setRepeatCount(Animation.INFINITE);//设置循环
    as.addAnimation(sa);
    as.addAnimation(aa);
    return as;
}
 
Example #28
Source File: AnimationService.java    From Pocket-Plays-for-Twitch with GNU General Public License v3.0 6 votes vote down vote up
public static void setAdapterInsertAnimation(final View aCard, int row, int height) {
	final int ANIMATION_DURATION = 650;
	final int BASE_DELAY = 50;

	TranslateAnimation translationAnimation = new TranslateAnimation(0,0, height,0);

	AlphaAnimation alphaAnimation = new AlphaAnimation(0f, 1f);

	final AnimationSet animationSet = new AnimationSet(true);
	animationSet.addAnimation(translationAnimation);
	animationSet.addAnimation(alphaAnimation);
	animationSet.setInterpolator(new AccelerateDecelerateInterpolator());
	animationSet.setFillAfter(true);
	animationSet.setFillBefore(true);
	animationSet.setDuration(ANIMATION_DURATION + row * BASE_DELAY);

	aCard.setAnimation(animationSet);
}
 
Example #29
Source File: SquareYMenu.java    From YMenuView with Apache License 2.0 5 votes vote down vote up
@Override
public Animation createOptionShowAnimation(OptionButton optionButton, int index) {
    float fromX,fromY;
    AnimationSet animationSet = new AnimationSet(true);
    if (index < 3){
        fromX = getYMenuButton().getX() - optionButton.getX();
        fromY = getYMenuButton().getY() - optionButton.getY();
    }else if (index < 6){
        fromX = getOptionButtonList().get(0).getX() - optionButton.getX();
        fromY = getOptionButtonList().get(0).getY() - optionButton.getY();
        animationSet.setStartOffset(getOptionSD_AnimationDuration() );
    }else {
        int oldIndex = index % 5;
        fromX = getOptionButtonList().get(oldIndex).getX() - optionButton.getX();
        fromY = getOptionButtonList().get(oldIndex).getY() - optionButton.getY();
        animationSet.setStartOffset(getOptionSD_AnimationDuration() );
    }

    TranslateAnimation translateAnimation= new TranslateAnimation(
            fromX
            ,0
            ,fromY
            ,0);
    translateAnimation.setDuration(getOptionSD_AnimationDuration());
    AlphaAnimation alphaAnimation = new AlphaAnimation(0,1);
    alphaAnimation.setDuration(getOptionSD_AnimationDuration());
    animationSet.addAnimation(alphaAnimation);
    animationSet.addAnimation(translateAnimation);
    animationSet.setInterpolator(new LinearInterpolator());
    return animationSet;

}
 
Example #30
Source File: AnimationFactory.java    From Android-Notification with Apache License 2.0 5 votes vote down vote up
/**
 * Create push down animation for entering.
 *
 * @return Animation
 */
public static Animation pushDownIn() {
    AnimationSet animationSet = new AnimationSet(true);
    animationSet.setFillAfter(true);
    animationSet.addAnimation(new TranslateAnimation(0, 0, -100, 0));
    animationSet.addAnimation(new AlphaAnimation(0.0f, 1.0f));
    return animationSet;
}