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

The following examples show how to use android.view.animation.AnimationSet#setDuration() . 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: InputPanel.java    From mollyim-android with GNU General Public License v3.0 6 votes vote down vote up
public ListenableFuture<Void> hide() {
  final SettableFuture<Void> future = new SettableFuture<>();

  AnimationSet animation = new AnimationSet(true);
  animation.addAnimation(new TranslateAnimation(Animation.ABSOLUTE, slideToCancelView.getTranslationX(),
                                                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 2
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 3
Source File: VoiceRecodingPanel.java    From bcm-android with GNU General Public License v3.0 6 votes vote down vote up
private void display(float x) {
    this.startPositionX = x;
    this.lastPositionX = x;

    recordButtonFab.setVisibility(VISIBLE);
    recordButtonFab.setX(getWidthAdjustment() + getOffset(x));

    AnimationSet animation = new AnimationSet(true);

    ScaleAnimation scaleAnimation = new ScaleAnimation(0.5f, 1f, 0.5f, 1f,
            Animation.RELATIVE_TO_SELF, 0.5f,
            Animation.RELATIVE_TO_SELF, 0.5f);
    animation.addAnimation(scaleAnimation);
    animation.setFillBefore(true);
    animation.setFillAfter(true);
    animation.setDuration(ANIMATION_DURATION);
    animation.setInterpolator(new OvershootInterpolator());

    recordButtonFab.startAnimation(animation);
}
 
Example 4
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 5
Source File: ZoomPageAnimator.java    From Paginize with MIT License 6 votes vote down vote up
private void initAnimations() {
  Animation inScaleAnimation = new ScaleAnimation(1.2f, 1, 1.2f, 1, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
  Animation inAlphaAnimation = new AlphaAnimation(0.0f, 1f);
  AnimationSet inAnimationSet = new AnimationSet(true);
  inAnimationSet.setDuration(ANIMATION_DURATION);
  inAnimationSet.addAnimation(inScaleAnimation);
  inAnimationSet.addAnimation(inAlphaAnimation);
  mInAnimation = inAnimationSet;

  Animation outScaleAnimation = new ScaleAnimation(1, 1.4f, 1, 1.4f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
  Animation outAlphaAnimation = new AlphaAnimation(1f, 0f);
  AnimationSet outAnimationSet = new AnimationSet(true);
  outAnimationSet.setDuration(ANIMATION_DURATION);
  outAnimationSet.addAnimation(outScaleAnimation);
  outAnimationSet.addAnimation(outAlphaAnimation);
  mOutAnimation = outAnimationSet;
}
 
Example 6
Source File: AnimationService.java    From Pocket-Plays-for-Twitch with GNU General Public License v3.0 6 votes vote down vote up
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 7
Source File: AnimationService.java    From Twire with GNU General Public License v3.0 6 votes vote down vote up
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 8
Source File: DailyNoteEditorActivity.java    From imsdk-android with MIT License 6 votes vote down vote up
public void startAnimation(View mView) {

        AlphaAnimation aa = new AlphaAnimation(0.4f, 1.0f); // 0完全透明 1 完全不透明
        // 以(0%,0.5%)为基准点,从0.5缩放至1
        ScaleAnimation sa = new ScaleAnimation(0.5f, 1, 0.5f, 1,
                Animation.RELATIVE_TO_SELF, 0,
                Animation.RELATIVE_TO_SELF, 0.5f);

        // 添加至动画集合
        AnimationSet as = new AnimationSet(false);
        as.addAnimation(aa);
        as.addAnimation(sa);
        as.setDuration(500);
        // 执行动画
        mView.startAnimation(as);
    }
 
Example 9
Source File: ShowFullScreenQrView.java    From bither-android with Apache License 2.0 5 votes vote down vote up
public void showPicFromPosition(final String content,
		final Bitmap placeHolder, final int x, final int y, final int width) {
	initView();
	setVisibility(View.VISIBLE);
	iv.setVisibility(View.INVISIBLE);
	ivPlaceHolder.setImageBitmap(placeHolder);
	final int size = Math.min(screenHeight, screenWidth);
	new Thread() {
		public void run() {
			final Bitmap bmp = Qr.bitmap(content, size);
			post(new Runnable() {
				@Override
				public void run() {
					iv.setImageBitmap(bmp);
					iv.setVisibility(View.VISIBLE);
				}
			});
		};
	}.start();
	AlphaAnimation animAlpha = new AlphaAnimation(0, 1);
	animAlpha.setDuration(AnimationDuration);
	vMask.startAnimation(animAlpha);
	int toX = 0;
	int toY = (screenHeight - statusBarHeight - screenWidth) / 2
			+ statusBarHeight;
	int toWidth = UIUtil.getScreenWidth();
	float scale = (float) width / (float) toWidth;
	ScaleAnimation animScale = new ScaleAnimation(scale, 1, scale, 1);
	animScale.setDuration(AnimationDuration);
	TranslateAnimation animTrans = new TranslateAnimation(x - toX, 0, y
			- toY, 0);
	animTrans.setDuration(AnimationDuration);
	AnimationSet animSet = new AnimationSet(true);
	animSet.setFillBefore(true);
	animSet.setDuration(AnimationDuration);
	animSet.addAnimation(animScale);
	animSet.addAnimation(animTrans);
	flImages.startAnimation(animSet);
}
 
Example 10
Source File: MyLayoutAnimationHelper.java    From RecyclerViewAnimation with Apache License 2.0 5 votes vote down vote up
/**
 * 从左侧进入,并带有弹性的动画
 *
 * @return
 */
public static AnimationSet getAnimationSetFromLeft() {
    AnimationSet animationSet = new AnimationSet(true);
    TranslateAnimation translateX1 = new TranslateAnimation(RELATIVE_TO_SELF, -1.0f, RELATIVE_TO_SELF, 0.1f,
            RELATIVE_TO_SELF, 0, RELATIVE_TO_SELF, 0);
    translateX1.setDuration(300);
    translateX1.setInterpolator(new DecelerateInterpolator());
    translateX1.setStartOffset(0);

    TranslateAnimation translateX2 = new TranslateAnimation(RELATIVE_TO_SELF, 0.1f, RELATIVE_TO_SELF, -0.1f,
            RELATIVE_TO_SELF, 0, RELATIVE_TO_SELF, 0);
    translateX2.setStartOffset(300);
    translateX2.setInterpolator(new DecelerateInterpolator());
    translateX2.setDuration(50);

    TranslateAnimation translateX3 = new TranslateAnimation(RELATIVE_TO_SELF, -0.1f, RELATIVE_TO_SELF, 0f,
            RELATIVE_TO_SELF, 0, RELATIVE_TO_SELF, 0);
    translateX3.setStartOffset(350);
    translateX3.setInterpolator(new DecelerateInterpolator());
    translateX3.setDuration(50);

    AlphaAnimation alphaAnimation = new AlphaAnimation(0.5f, 1.0f);
    alphaAnimation.setDuration(400);
    alphaAnimation.setInterpolator(new AccelerateDecelerateInterpolator());


    animationSet.addAnimation(translateX1);
    animationSet.addAnimation(translateX2);
    animationSet.addAnimation(translateX3);
    //animationSet.addAnimation(alphaAnimation);
    animationSet.setDuration(400);

    return animationSet;
}
 
Example 11
Source File: ArcMenu.java    From timecat with 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 12
Source File: ParallaxedView.java    From ParallaxScroll with MIT License 5 votes vote down vote up
protected synchronized void animateNow() {
    View view = this.view.get();
    if (view != null) {
        AnimationSet set = new AnimationSet(true);
        for (Animation animation : animations)
            if (animation != null)
                set.addAnimation(animation);
        set.setDuration(0);
        set.setFillAfter(true);
        view.setAnimation(set);
        set.start();
        animations.clear();
    }
}
 
Example 13
Source File: MyLayoutAnimationHelper.java    From RecyclerViewAnimation with Apache License 2.0 5 votes vote down vote up
/**
 * 缩小动画
 *
 * @return
 */
public static AnimationSet getAnimationSetScaleNarrow() {
    AnimationSet animationSet = new AnimationSet(true);

    ScaleAnimation scaleAnimation = new ScaleAnimation(2.1f, 1.0f, 2.1f, 1.0f, RELATIVE_TO_SELF, 0.5f, RELATIVE_TO_SELF, 0.5f);
    scaleAnimation.setInterpolator(new DecelerateInterpolator());
    scaleAnimation.setDuration(400);

    animationSet.addAnimation(scaleAnimation);
    animationSet.setDuration(400);

    return animationSet;
}
 
Example 14
Source File: LoadingActivity.java    From DoingDaily with Apache License 2.0 5 votes vote down vote up
@Override
public Animation createLogoAnimation() {
    ScaleAnimation tvScaleAnim = new ScaleAnimation(1.0f, 1.3f, 1.0f, 1.3f
            , Animation.RELATIVE_TO_SELF, 0.5F, Animation.RELATIVE_TO_SELF, 0.5f);
    TranslateAnimation tvTranslateAnim = new TranslateAnimation(0, 0, 0, -40);

    AnimationSet animationSet = new AnimationSet(true);
    animationSet.addAnimation(tvScaleAnim);
    animationSet.addAnimation(tvTranslateAnim);
    animationSet.setDuration(3000);
    animationSet.setFillAfter(true);
    return animationSet;
}
 
Example 15
Source File: MyLayoutAnimationHelper.java    From RecyclerViewAnimation with Apache License 2.0 5 votes vote down vote up
/**
 * 从顶部进入
 *
 * @return
 */
public static AnimationSet getAnimationSetFromTop() {
    AnimationSet animationSet = new AnimationSet(true);
    TranslateAnimation translateX1 = new TranslateAnimation(RELATIVE_TO_SELF, 0, RELATIVE_TO_SELF, 0,
            RELATIVE_TO_SELF, -2.5f, RELATIVE_TO_SELF, 0);
    translateX1.setDuration(400);
    translateX1.setInterpolator(new DecelerateInterpolator());
    translateX1.setStartOffset(0);

    animationSet.addAnimation(translateX1);
    animationSet.setDuration(400);

    return animationSet;
}
 
Example 16
Source File: ArcMenu.java    From UltimateAndroid with 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 17
Source File: VoiceRecodingPanel.java    From bcm-android with GNU General Public License v3.0 5 votes vote down vote up
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 18
Source File: AnnularMenu.java    From AnnularMenuView with Apache License 2.0 5 votes vote down vote up
private Animation scaleSmallAnimation(int duration) {
    AnimationSet animationSet = new AnimationSet(true);
    ScaleAnimation scaleAnimation = new ScaleAnimation(1.0f, 0.0f, 1.0f, 0.0f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5F);
    AlphaAnimation alphaAnimation = new AlphaAnimation(1.0f, 0.0f);
    animationSet.addAnimation(scaleAnimation);
    animationSet.addAnimation(alphaAnimation);
    animationSet.setDuration(duration);
    animationSet.setFillAfter(true);
    return animationSet;
}
 
Example 19
Source File: MyLayoutAnimationHelper.java    From RecyclerViewAnimation with Apache License 2.0 5 votes vote down vote up
/**
 * 旋转动画
 *
 * @return
 */
public static AnimationSet getAnimationSetRotation() {
    AnimationSet animationSet = new AnimationSet(true);

    RotateAnimation rotateAnimation = new RotateAnimation(30, 0, RELATIVE_TO_SELF, 0.5f, RELATIVE_TO_SELF, 0.5f);
    rotateAnimation.setDuration(400);
    rotateAnimation.setInterpolator(new DecelerateInterpolator());

    animationSet.addAnimation(rotateAnimation);
    animationSet.setDuration(400);

    return animationSet;
}
 
Example 20
Source File: AnimationUtils.java    From Lay-s with MIT License 4 votes vote down vote up
public static Animation clickAnimation(float scaleXY, long durationMillis) {
    AnimationSet set = new AnimationSet(true);
    set.addAnimation(getScaleAnimation(scaleXY, durationMillis));
    set.setDuration(durationMillis);
    return set;
}