private AnimationSet startHideContinueIconAnimations() { Animation mScaleAnimation = new ScaleAnimation(1, 0, 1, 0, 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; }
@Override protected void animateAddImpl(final RecyclerView.ViewHolder holder) { View target = holder.itemView; View icon = target.findViewById(R.id.icon); Animator swing = ObjectAnimator.ofFloat(icon, "rotationX", 45, 0); swing.setInterpolator(new OvershootInterpolator(5)); View right = holder.itemView.findViewById(R.id.right); Animator rotateIn = ObjectAnimator.ofFloat(right, "rotationY", 90, 0); rotateIn.setInterpolator(new DecelerateInterpolator()); AnimatorSet animator = new AnimatorSet(); animator.setDuration(getAddDuration()); animator.playTogether(swing, rotateIn); animator.start(); }
@Override public void setData(Mail data) { this.mail = data; senderImageView.setImageResource(data.getSender().getImageRes()); senderNameView.setText(data.getSender().getName()); senderMailView.setText(data.getSender().getEmail()); subjectView.setText(data.getSubject()); contentView.setText(data.getText() + data.getText() + data.getText() + data.getText()); starView.setStarred(data.isStarred()); dateView.setText(format.format(data.getDate())); labelView.setMail(data); labelView.setVisibility(View.VISIBLE); replayView.setVisibility(View.VISIBLE); // Animate only if not restoring if (!isRestoringViewState()) { labelView.setAlpha(0f); labelView.animate().alpha(1f).setDuration(150).start(); PropertyValuesHolder holderX = PropertyValuesHolder.ofFloat("scaleX", 0, 1); PropertyValuesHolder holderY = PropertyValuesHolder.ofFloat("scaleY", 0, 1); ObjectAnimator animator = ObjectAnimator.ofPropertyValuesHolder(replayView, holderX, holderY); animator.setInterpolator(new OvershootInterpolator()); animator.start(); } }
@Override protected void onFocusChanged(boolean gainFocus, int direction, Rect previouslyFocusedRect) { super.onFocusChanged(gainFocus, direction, previouslyFocusedRect); if (mFocusAnim != null) { mFocusAnim.end(); } if (gainFocus) { mFocusAnim = ObjectAnimator.ofFloat(this, "FocusLine", mFocusLineLength, (float) (getWidth() - 2 * mRoundRadius)); input.showSoftInput(this, InputMethodManager.SHOW_FORCED); } else { mFocusAnim = ObjectAnimator.ofFloat(this, "FocusLine", mFocusLineLength, 0); input.hideSoftInputFromInputMethod(this.getWindowToken(), 0); } mFocusAnim.setDuration(1000).setInterpolator(new OvershootInterpolator()); mFocusAnim.start(); }
@SuppressWarnings("NewApi") private void showMenu() { menuLayout.setVisibility(View.VISIBLE); List<Animator> animList = new ArrayList<>(); for (int i = 0, len = arcLayout.getChildCount(); i < len; i++) { animList.add(createShowItemAnimator(arcLayout.getChildAt(i))); } AnimatorSet animSet = new AnimatorSet(); animSet.setDuration(400); animSet.setInterpolator(new OvershootInterpolator()); animSet.playTogether(animList); animSet.start(); }
public void releaseView() { if (mAnimator==null){ final ValueAnimator valAnimator=ValueAnimator.ofFloat(mPercent,0f); valAnimator.setDuration(500); valAnimator.setInterpolator(new OvershootInterpolator()); valAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator valueAnimator) { float animValue= (float) valAnimator.getAnimatedValue(); setPercent(animValue); } }); this.mAnimator=valAnimator; }else { mAnimator.cancel(); mAnimator.setFloatValues(mPercent,0f); } mAnimator.start(); }
public void display(float x) { this.startPositionX = x; this.lastPositionX = x; recordButtonFab.setVisibility(View.VISIBLE); float translation = ViewCompat.getLayoutDirection(recordButtonFab) == ViewCompat.LAYOUT_DIRECTION_LTR ? -.25f : .25f; AnimationSet animation = new AnimationSet(true); animation.addAnimation(new TranslateAnimation(Animation.RELATIVE_TO_SELF, translation, Animation.RELATIVE_TO_SELF, translation, 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); }
/** * Animate the views too look more lively */ public void show() { LinearLayout layout = (LinearLayout) getChildAt(0); layout.setScaleY(0); layout.animate().scaleY(1).setDuration(150).start(); for (int i = 0; i < layout.getChildCount(); i++) { View v = layout.getChildAt(i); v.setScaleX(0); v.setScaleY(0); v.animate().scaleX(1).scaleY(1).setDuration(100) .setStartDelay((80 * i) + 150) .setInterpolator(new OvershootInterpolator()) .start(); } }
private void loadThumbnailPhoto() { ivPhoto.setScaleX(0); ivPhoto.setScaleY(0); Picasso.with(this) .load(photoUri) .centerCrop() .resize(photoSize, photoSize) .into(ivPhoto, new Callback() { @Override public void onSuccess() { ivPhoto.animate() .scaleX(1.f).scaleY(1.f) .setInterpolator(new OvershootInterpolator()) .setDuration(400) .setStartDelay(200) .start(); } @Override public void onError() { } }); }
private void addScaleAnimation(int startDelay, int duration, AnimatorSet set){ final int start=!isFolded?1:0; final int end =~start & 0x1; AnimatorSet buttonSet=new AnimatorSet(); for(int index=0;index<dots.size();index++){ FloatingActionButton tempDot=dots.get(index); if(tempDot.getId()!=lastDot.getId()){ ObjectAnimator scaleX=ObjectAnimator.ofFloat(tempDot,View.SCALE_X,start,end); ObjectAnimator scaleY=ObjectAnimator.ofFloat(tempDot,View.SCALE_Y,start,end); ObjectAnimator fade=ObjectAnimator.ofFloat(tempDot,View.ALPHA,start,end); scaleX.setStartDelay(startDelay); scaleY.setStartDelay(startDelay); scaleX.setInterpolator(new OvershootInterpolator(2)); scaleY.setInterpolator(new OvershootInterpolator(2)); fade.setStartDelay(startDelay); buttonSet.playTogether(scaleX,scaleY,fade); } } buttonSet.setDuration(duration); set.playTogether(buttonSet); }
private void performShowAnimation() { contextMenuView.setPivotX(contextMenuView.getWidth() / 2); contextMenuView.setPivotY(contextMenuView.getHeight()); contextMenuView.setScaleX(0.1f); contextMenuView.setScaleY(0.1f); contextMenuView.animate() .scaleX(1f).scaleY(1f) .setDuration(150) .setInterpolator(new OvershootInterpolator()) .setListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { isContextMenuShowing = false; } }); }
AnimationTask() { if (mIsAnimationLocked) throw new RuntimeException("Returning to user's finger. Avoid animations while mIsAnimationLocked flag is set."); mDestX = calculateX(); mDestY = calculateY(); mDynamicUpdate = null; setAnimationFinishedListener(new AnimationFinishedListener() { @Override public void onAnimationFinished() { adjustInactivePosition(); } }); float velocityX = calculateVelocityX(); float velocityY = calculateVelocityY(); mTension += Math.sqrt(sqr(velocityX) + sqr(velocityY)) / 200; mInterpolator = new OvershootInterpolator(mTension); mCurrentPosX = mDestX; mCurrentPosY = mDestY; }
private void init() { configuration = ViewConfiguration.get(getContext()); mScroller = new Scroller(getContext(), new OvershootInterpolator(0.75f)); flingRunnable = new FlingRunnable(); overScrollRunnable = new OverScrollRunnable(); flingScroller = new OverScroller(getContext()); detector = new GestureDetector(getContext(), new GestureDetector.SimpleOnGestureListener() { @Override public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) { if (isOverScrollTop || isOverScrollBottom || isOverScrollLeft || isOverScrollRight) { return false; } // flingRunnable.start(velocityX, velocityY); return false; } }); }
@Override public void setData(HotMovieBean.SubjectsBean data) { super.setData(data); ImageLoader.load(data.getImages().getLarge(), ivRanking, 200); tvRankingTitle.setText(data.getTitle()); tvDirectContent.setText(StringFormatUtil.formatName(data.getDirectors())); tvActorContent.setText(StringFormatUtil.formatName(data.getCasts(), true)); tvTypeContent.setText(StringFormatUtil.formatGenres(data.getGenres())); tvScoreContent.setText(String.valueOf(data.getRating().getAverage())); //动画 itemView.setScaleX(0.8f); itemView.setScaleY(0.8f); itemView.animate().scaleX(1).setDuration(350).setInterpolator(new OvershootInterpolator()).start(); itemView.animate().scaleY(1).setDuration(350).setInterpolator(new OvershootInterpolator()).start(); // itemView.setOnClickListener(view -> MovieDetailsActivity.startAction((Activity) getContext(), data, ivRanking)); }
/** * Animates the passed view as following :scale downed to 0 , * reduced alpha to 0 and a 360 degree rotation if allowed * @param view the view to animate * @param delay delay before starting the animation */ void animateMenuItemClose(View view,long delay){ ObjectAnimator animScaleX = ObjectAnimator.ofFloat(view,"scaleX",1.0f,0.2f); ObjectAnimator animScaleY = ObjectAnimator.ofFloat(view,"scaleY",1.0f,0.2f); ObjectAnimator animAlpha = ObjectAnimator.ofFloat(view,"alpha",ITEM_FINAL_ALPHA,0.0f); ObjectAnimator animRotation = ObjectAnimator.ofFloat(view,"rotation",360.0f,0); final int X_SCALE_ANIMATION_DURATION = 400; final int Y_SCALE_ANIMATION_DURATION = 400; final int ALPHA_ANIMATION_DURATION = 300; animScaleX.setDuration(X_SCALE_ANIMATION_DURATION); animScaleY.setDuration(Y_SCALE_ANIMATION_DURATION); animAlpha.setDuration(ALPHA_ANIMATION_DURATION); animRotation.setDuration(500); AnimatorSet animSet = new AnimatorSet(); if(allowItemRotationAnim) animSet.playTogether(animScaleX,animScaleY,animAlpha,animRotation); else animSet.playTogether(animScaleX,animScaleY,animAlpha); animSet.setInterpolator(new OvershootInterpolator(2)); animSet.setStartDelay(delay); animSet.start(); }
@Override public void startAnimation(final DynamicWeatherView dynamicWeatherView, int fromColor) { super.startAnimation(dynamicWeatherView, fromColor); ValueAnimator animator1 = ValueAnimator.ofFloat(0, 1); animator1.setInterpolator(new OvershootInterpolator()); animator1.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { speed = (float) animation.getAnimatedValue() * 32; rotate = (float) animation.getAnimatedValue(); } }); AnimatorSet animSet = new AnimatorSet(); animSet.play(animator1); animSet.setDuration(1000); animSet.start(); }
@Override public void startAnimation(DynamicWeatherView dynamicWeatherView, int fromColor) { super.startAnimation(dynamicWeatherView, fromColor); ValueAnimator animator = ValueAnimator.ofFloat(-bitmap.getWidth() * 0.25f, getWidth() - bitmap.getWidth() * 0.25f); animator.setDuration(1000); animator.setRepeatCount(0); animator.setInterpolator(new OvershootInterpolator()); animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { transFactor = (float) animation.getAnimatedValue(); } }); animator.start(); }
private void animator(final View itemView, final Filter item, final FloatImgBean floatImg, int startX, int startY, int endX, int endY) { ObjectAnimator animatorX = ObjectAnimator.ofFloat(floatImg.mImageView, "translationX", startX - mStartX, endX - mStartX); ObjectAnimator animatorY = ObjectAnimator.ofFloat(floatImg.mImageView, "translationY", startY - mStartY, endY - mStartY); AnimatorSet animatorSet = new AnimatorSet(); animatorSet.playTogether(animatorX, animatorY); animatorSet.setDuration(calcDuration(startX - endX, startY - endY)); animatorSet.setInterpolator(new OvershootInterpolator(1.1f)); animatorSet.start(); animatorSet.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { floatImg.mImageView.setVisibility(View.GONE); floatImg.mIsAnimator = false; mIconListRvAdapter.add(item); mIconRecyclerView.smoothScrollToPosition(mIconListRvAdapter.getItemCount()); mPlaceHolder.setVisibility(View.GONE); refreshLayout(false); itemView.setClickable(true); } }); }
@Override public void onExpansionToggled(boolean expanded) { super.onExpansionToggled(expanded); ObjectAnimator imageViewObjectAnimator; if (expanded) { // rotate clockwise imageViewObjectAnimator = ObjectAnimator.ofFloat(mArrowExpandImageView , View.ROTATION, ROTATED_POSITION,INITIAL_POSITION); } else { // rotate counterclockwise imageViewObjectAnimator = ObjectAnimator.ofFloat(mArrowExpandImageView , View.ROTATION,INITIAL_POSITION, ROTATED_POSITION); } imageViewObjectAnimator.setDuration(1000); imageViewObjectAnimator.setInterpolator(new OvershootInterpolator()); imageViewObjectAnimator.start(); }
protected void showCurrentWord(String letter) { currentWord.setText(letter); if(!isScale){ isScale = true; ViewPropertyAnimator.animate(currentWord).scaleX(1f) .setInterpolator(new OvershootInterpolator()) .setDuration(450).start(); ViewPropertyAnimator.animate(currentWord).scaleY(1f) .setInterpolator(new OvershootInterpolator()) .setDuration(450).start(); } //先移除之前的任务 handler.removeCallbacksAndMessages(null); //延时隐藏currentWord handler.postDelayed(new Runnable() { @Override public void run() { // currentWord.setVisibility(View.INVISIBLE); ViewPropertyAnimator.animate(currentWord).scaleX(0f).setDuration(450).start(); ViewPropertyAnimator.animate(currentWord).scaleY(0f).setDuration(450).start(); isScale = false; } }, 1500); }
private void loadThumbnailPhoto() { ivPhoto.setScaleX(0); ivPhoto.setScaleY(0); Picasso.with(this) .load(photoUri) .centerCrop() .resize(photoSize, photoSize) .into(ivPhoto, new Callback() { @Override public void onSuccess() { ivPhoto.animate() .scaleX(1.f).scaleY(1.f) .setInterpolator(new OvershootInterpolator()) .setDuration(400) .setStartDelay(200) .start(); } @Override public void onError() { Toast.makeText(getApplicationContext(), "error", Toast.LENGTH_LONG).show(); } }); }
/** * アクションする削除アイコンの設定を更新します。 * * @param width 対象となるViewの幅 * @param height 対象となるViewの高さ * @param shape 対象となるViewの形状 */ void updateActionTrashIcon(float width, float height, float shape) { // アクションする削除アイコンが設定されていない場合は何もしない if (!hasActionTrashIcon()) { return; } // 拡大率の設定 mAnimationHandler.mTargetWidth = width; mAnimationHandler.mTargetHeight = height; final float newWidthScale = width / mActionTrashIconBaseWidth * shape; final float newHeightScale = height / mActionTrashIconBaseHeight * shape; mActionTrashIconMaxScale = Math.max(newWidthScale, newHeightScale); // ENTERアニメーション作成 mEnterScaleAnimator = ObjectAnimator.ofPropertyValuesHolder(mActionTrashIconView, PropertyValuesHolder.ofFloat(ImageView.SCALE_X, mActionTrashIconMaxScale), PropertyValuesHolder.ofFloat(ImageView.SCALE_Y, mActionTrashIconMaxScale)); mEnterScaleAnimator.setInterpolator(new OvershootInterpolator()); mEnterScaleAnimator.setDuration(TRASH_ICON_SCALE_DURATION_MILLIS); // Exitアニメーション作成 mExitScaleAnimator = ObjectAnimator.ofPropertyValuesHolder(mActionTrashIconView, PropertyValuesHolder.ofFloat(ImageView.SCALE_X, 1.0f), PropertyValuesHolder.ofFloat(ImageView.SCALE_Y, 1.0f)); mExitScaleAnimator.setInterpolator(new OvershootInterpolator()); mExitScaleAnimator.setDuration(TRASH_ICON_SCALE_DURATION_MILLIS); }
@Override public boolean onTouchEvent(MotionEvent ev) { if (ev.getAction() == MotionEvent.ACTION_UP) { // 恢复高度 final ValueAnimator animator = ValueAnimator.ofInt(parallaxImageView.getHeight(), originalHeight); animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator valueAnimator) { Integer animateValue = (Integer) animator.getAnimatedValue(); // 给 ImageView 设置值 parallaxImageView.getLayoutParams().height = animateValue; parallaxImageView.requestLayout(); } }); animator.setInterpolator(new OvershootInterpolator()); // 弹性差值器 animator.setDuration(450); animator.start(); } return super.onTouchEvent(ev); }
private void animateResult(boolean success, @Nullable String extraMsg) { mainContainer.setVisibility(View.GONE); loadingContainer.setVisibility(View.GONE); resultContainer.setVisibility(View.VISIBLE); resultText.setText(success ? R.string.result_success : R.string.result_fail); resultExtraMsg.setText(extraMsg); resultContainer.setAlpha(0f); resultContainer.animate() .setDuration(100) .alpha(1f); resultIcon.setImageResource(success ? R.drawable.ic_check : R.drawable.ic_clear); resultIcon.setScaleX(0f); resultIcon.setScaleY(0f); resultIcon.animate() .scaleX(1f) .scaleY(1f) .setInterpolator(new OvershootInterpolator()); }
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; }
public void setChecked(boolean checked) { if (checked == isChecked()) { return; } if (checked) { viewDot.setScaleX(0); viewDot.setScaleY(0); viewDot.setVisibility(View.VISIBLE); viewDot.animate() .scaleX(1.0f) .scaleY(1.0f) .setInterpolator(new OvershootInterpolator()) .start(); } else { viewDot.setVisibility(View.GONE); } }
@Override public void showTitle(String title) { playlistTitle.setText(title); playlistTitle.setScaleX(0);playlistTitle.setScaleY(0); titleBackground.post(()->{ int cx=titleBackground.getWidth()/2; int cy=titleBackground.getHeight()/2; Animator animator=ViewAnimationUtils.createCircularReveal(titleBackground,cx,cy,0, (int)Math.hypot(titleBackground.getWidth(),titleBackground.getHeight())); animator.setDuration(400); animator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animation) { super.onAnimationStart(animation); titleBackground.setVisibility(View.VISIBLE); playlistTitle.animate() .setDuration(400) .scaleX(1).scaleY(1) .setInterpolator(new OvershootInterpolator()) .start(); } }); animator.start(); }); }
private void showFAB() { mFAB.animate().scaleX(1f).scaleY(1f) .setInterpolator(new OvershootInterpolator()) .start(); mFAB.setClickable(true); }
public PoemViewHolder(View view) { super(view); tv=(TextView) view.findViewById(R.id.item_tv); expandableLayout = (ExpandableLayout) itemView.findViewById(R.id.expandable_layout); expandText=(TextView)itemView.findViewById(R.id.expandable_text); expandableLayout.setInterpolator(new OvershootInterpolator()); expandableLayout.setOnExpansionUpdateListener(this); tv.setOnClickListener(this); }
private void startContentAnimation() { fabCreate.animate() .translationY(0) .setInterpolator(new OvershootInterpolator(1.f)) .setStartDelay(300) .setDuration(ANIM_DURATION_FAB) .start(); feedAdapter.updateItems(true); }
@Override protected void animateAddImpl(final RecyclerView.ViewHolder holder, final int index) { ViewCompat.animate(holder.itemView) .translationX(0) .setDuration(getAddDuration()) .setInterpolator(new OvershootInterpolator(mTension)) .setListener(new DefaultAddVpaListener(holder)) .start(); }
@Override protected void animateAddImpl(final RecyclerView.ViewHolder holder, final int index) { ViewCompat.animate(holder.itemView) .translationX(0) .setDuration(getAddDuration()) .setListener(new DefaultAddVpaListener(holder)) .setInterpolator(new OvershootInterpolator(mTension)) .start(); }
@Override protected Animation initShowAnimation() { TranslateAnimation translateAnimation = new TranslateAnimation(0f, 0f, -DimensUtils.dipToPx(getContext(), 350f), 0); translateAnimation.setDuration(450); translateAnimation.setInterpolator(new OvershootInterpolator(1)); return translateAnimation; }
@Override protected Animation initExitAnimation() { TranslateAnimation translateAnimation = new TranslateAnimation(0f, 0f, 0, -DimensUtils.dipToPx(getContext(), 350f)); translateAnimation.setDuration(450); translateAnimation.setInterpolator(new OvershootInterpolator(-4)); return translateAnimation; }
@Override public void showContent() { super.showContent(); if (createMailButton.getVisibility() != View.VISIBLE) { createMailButton.setVisibility(View.VISIBLE); if (!isRestoringViewState()) { PropertyValuesHolder holderX = PropertyValuesHolder.ofFloat("scaleX", 0, 1); PropertyValuesHolder holderY = PropertyValuesHolder.ofFloat("scaleY", 0, 1); ObjectAnimator animator = ObjectAnimator.ofPropertyValuesHolder(createMailButton, holderX, holderY); animator.setInterpolator(new OvershootInterpolator()); animator.start(); } } }
private ValueAnimator createNewAppBounceAnimation(View v, int i) { ValueAnimator bounceAnim = LauncherAnimUtils.ofViewAlphaAndScale(v, 1, 1, 1); bounceAnim.setDuration(InstallShortcutReceiver.NEW_SHORTCUT_BOUNCE_DURATION); bounceAnim.setStartDelay(i * InstallShortcutReceiver.NEW_SHORTCUT_STAGGER_DELAY); bounceAnim.setInterpolator(new OvershootInterpolator(BOUNCE_ANIMATION_TENSION)); return bounceAnim; }