private void showIcons(final boolean show) { for (int i = 0; i < getChildCount(); i++) { final View view = getChildAt(i); int translation = menuAnchor == MENU_ANCHOR_BOTTOM ? view.getHeight() : -view.getHeight(); view.setTranslationY(show ? translation : 0f); view.setScaleX(show ? 0f : 1f); view.setScaleY(show ? 0f : 1f); view.setVisibility(VISIBLE); view.setAlpha(show ? 0f : 1f); view.animate() .scaleX(show ? 1f : 0f) .scaleY(show ? 1f : 0f) .translationY(0f) .alpha(show ? 1f : 0f) .setInterpolator(DECELERATE_INTERPOLATOR) .setDuration(show ? animationDuration / 2 : animationDuration / 3) .setStartDelay(show ? animationDuration / 3 : 0) .setListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); view.setVisibility(show ? VISIBLE : GONE); } }) .start(); } }
@Override public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) { if (position < getItemCount() && (customHeaderView != null ? position <= stringList.size() : position < stringList.size()) && (customHeaderView != null ? position > 0 : true)) { ((ViewHolder) holder).textViewSample.setText(stringList.get(customHeaderView != null ? position - 1 : position)); // ((ViewHolder) holder).itemView.setActivated(selectedItems.get(position, false)); } if (!isFirstOnly || position > mLastPosition) { for (Animator anim : getAdapterAnimations(holder.itemView, AdapterAnimationType.ScaleIn)) { anim.setDuration(mDuration).start(); anim.setInterpolator(mInterpolator); } mLastPosition = position; } else { ViewHelper.clear(holder.itemView); } }
private void animateInFrameDetails() { frameDetails.setVisibility(View.VISIBLE); ViewUtils.onLaidOut(frameDetails, new Runnable() { @Override public void run() { ObjectAnimator alpha = ObjectAnimator.ofFloat(frameDetails, View.ALPHA, 0.4f, 1f); ObjectAnimator translate = ofFloat(frameDetails, View.TRANSLATION_Y, frameDetails.getHeight() * 0.3f, 0f); AnimatorSet set = new AnimatorSet(); set.playTogether(alpha, translate); set.setDuration(ANIM_DURATION); set.setInterpolator(new LinearOutSlowInInterpolator()); set.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); frameMaster.setVisibility(View.GONE); } }); set.start(); } }); }
private void runIconScale(int delay, @DrawableRes int drawable, int color){ soundPlay.animate() .scaleY(0) .scaleX(0) .setDuration(duration(R.integer.short_delay)) .setStartDelay(delay) .setListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); trackTitle.setTextColor(color); soundPlay.setImageDrawable(ContextCompat.getDrawable(getContext(),drawable)); soundPlay.animate() .scaleX(1) .scaleY(1) .setDuration(duration(R.integer.scale_duration)) .setListener(null).start(); } }).start(); }
@Override public List<Animator> getAnimators() { final List<Animator> animations = new ArrayList<>(); calculate(); if (mCameraDistance != null) { final ValueAnimator animator = ValueAnimator.ofFloat(mCurrentCameraDistance, mCameraDistance); animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator valueAnimator) { viewToMove.setCameraDistance((float) valueAnimator.getAnimatedValue()); } }); animations.add(animator); } return animations; }
public List<Animator> createAnimation() { List<Animator> animators = new ArrayList<>(); int[] delays = new int[]{120, 240, 360}; for (int i = 0; i < 3; i++) { final int index = i; ValueAnimator scaleAnim = ValueAnimator.ofFloat(1, 0.3f, 1); scaleAnim.setDuration(750); scaleAnim.setRepeatCount(-1); scaleAnim.setStartDelay(delays[i]); scaleAnim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { scaleFloats[index] = (float) animation.getAnimatedValue(); postInvalidate(); } }); scaleAnim.start(); animators.add(scaleAnim); } return animators; }
private ObjectAnimator createEnterTabSwitcherModeAnimation() { ObjectAnimator enterAnimation = ObjectAnimator.ofFloat(this, mTabSwitcherModePercentProperty, 1.f); enterAnimation.setDuration(TAB_SWITCHER_MODE_ENTER_ANIMATION_DURATION_MS); enterAnimation.setInterpolator(new LinearInterpolator()); enterAnimation.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { // This is to deal with the view going invisible when resuming the activity and // running this animation. The view is still there and clickable but does not // render and only a layout triggers a refresh. See crbug.com/306890. if (!mToggleTabStackButton.isEnabled()) requestLayout(); } }); return enterAnimation; }
private void setDimVisibility(final boolean visible) { Animator animator; if (visible) { dimView.setVisibility(VISIBLE); animator = ObjectAnimator.ofFloat(dimView, "alpha", 0.0f, 1.0f); } else { animator = ObjectAnimator.ofFloat(dimView, "alpha", 1.0f, 0.0f); } animator.addListener(new AnimatorListenerAdapterProxy() { @Override public void onAnimationEnd(Animator animation) { if (!visible) { dimView.setVisibility(GONE); } } }); animator.setDuration(200); animator.start(); }
/** * 向四周伸张,直到完成显示。 */ @SuppressLint("NewApi") public static void show(View myView, float startRadius, long durationMills) { if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.LOLLIPOP) { myView.setVisibility(View.VISIBLE); return; } int cx = (myView.getLeft() + myView.getRight()) / 2; int cy = (myView.getTop() + myView.getBottom()) / 2; int w = myView.getWidth(); int h = myView.getHeight(); // 勾股定理 & 进一法 int finalRadius = (int) Math.sqrt(w * w + h * h) + 1; Animator anim = ViewAnimationUtils.createCircularReveal(myView, cx, cy, startRadius, finalRadius); myView.setVisibility(View.VISIBLE); anim.setDuration(durationMills); anim.start(); }
private void hideRecordedAudioPanel() { audioToSendPath = null; audioToSend = null; audioToSendMessageObject = null; AnimatorSet AnimatorSet = new AnimatorSet(); AnimatorSet.playTogether( ObjectAnimator.ofFloat(recordedAudioPanel, "alpha", 0.0f) ); AnimatorSet.setDuration(200); AnimatorSet.addListener(new AnimatorListenerAdapterProxy() { @Override public void onAnimationEnd(Animator animation) { recordedAudioPanel.setVisibility(GONE); } }); AnimatorSet.start(); }
private void fadeOut() { contentView.setAlpha(0f); contentView.setVisibility(View.VISIBLE); contentView.animate() .alpha(1f) .setDuration(getResources().getInteger( android.R.integer.config_longAnimTime)) .setListener(null); loadingView.animate() .alpha(0f) .setDuration(getResources().getInteger( android.R.integer.config_longAnimTime)) .setListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { loadingView.setVisibility(View.GONE); } }); }
private void exitReveal(final View icon, final View toolbar) { // get the center for the clipping circle int cx = getRelativeLeft(icon) + icon.getMeasuredWidth() / 2; int cy = getRelativeTop(icon); // get the initial radius for the clipping circle int initialRadius = Math.max(toolbar.getWidth(), toolbar.getHeight()); // create the animation (the final radius is zero) Animator anim = ViewAnimationUtils.createCircularReveal(toolbar, cx, cy, initialRadius, 0); // make the view invisible when the animation is done anim.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); toolbar.setVisibility(View.INVISIBLE); } }); anim.setDuration(Constant.SEARCH_REVEAL_DURATION); // start the animation anim.start(); }
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; } }); }
void Play(int val){ final ImageView iv = top; top = btm; btm = creatImg(); btm.setImageBitmap(BM); addView(btm,0); Set = new AnimatorSet(); Set.setInterpolator(Ui.cd.TH); Set.playTogether(ObjectAnimator.ofFloat(iv, "X",val)); Set.setDuration(500).start(); Set.addListener(new animLis(){ @Override public void onAnimationEnd(Animator animation) { imgSlider.this.removeView(iv); } }); }
/** * keyframe */ private void keyFrame() { Keyframe keyframe0 = Keyframe.ofFloat(0f, 0); Keyframe keyframe1 = Keyframe.ofFloat(0.1f, 20f); Keyframe keyframe2 = Keyframe.ofFloat(0.2f, -20f); Keyframe keyframe3 = Keyframe.ofFloat(0.3f, 20f); Keyframe keyframe4 = Keyframe.ofFloat(0.4f, -20f); Keyframe keyframe5 = Keyframe.ofFloat(0.5f, 20f); Keyframe keyframe6 = Keyframe.ofFloat(0.6f, -20f); Keyframe keyframe7 = Keyframe.ofFloat(0.7f, 20f); Keyframe keyframe8 = Keyframe.ofFloat(0.8f, -20f); Keyframe keyframe9 = Keyframe.ofFloat(0.9f, 20f); Keyframe keyframe10 = Keyframe.ofFloat(1f, 0); PropertyValuesHolder holder = PropertyValuesHolder.ofKeyframe("rotation", keyframe0, keyframe1, keyframe2, keyframe3, keyframe4, keyframe5, keyframe6, keyframe7, keyframe8, keyframe9, keyframe10); Animator animator = ObjectAnimator.ofPropertyValuesHolder(content, holder); animator.setDuration(2000); animator.start(); }
/** * add animation when you want to show time * * @param holder */ private void addAnimation(RecyclerView.ViewHolder holder) { if (mOpenAnimationEnable) { if (!mFirstOnlyEnable || holder.getLayoutPosition() > mLastPosition) { BaseAnimation animation = null; if (mCustomAnimation != null) { animation = mCustomAnimation; } else { animation = mSelectAnimation; } for (Animator anim : animation.getAnimators(holder.itemView)) { startAnim(anim, holder.getLayoutPosition()); } mLastPosition = holder.getLayoutPosition(); } } }
private void setupAnimation(View view, final Animator animation, final int animationID) { view.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { // If the button is checked, load the animation from the given resource // id instead of using the passed-in animation parameter. See the xml files // for the details on those animations. if (mCheckBox.isChecked()) { Animator anim = AnimatorInflater.loadAnimator(PropertyAnimations.this, animationID); anim.setTarget(v); anim.start(); return; } animation.start(); } }); }
@Override public List<Animator> createAnimation() { List<Animator> animators=new ArrayList<>(); long[] delays=new long[]{100,200,300,400,500}; for (int i = 0; i < 5; i++) { final int index=i; ValueAnimator scaleAnim=ValueAnimator.ofFloat(1, 0.4f, 1); scaleAnim.setDuration(1000); scaleAnim.setRepeatCount(-1); scaleAnim.setStartDelay(delays[i]); scaleAnim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { scaleYFloats[index] = (float) animation.getAnimatedValue(); postInvalidate(); } }); scaleAnim.start(); animators.add(scaleAnim); } return animators; }
@Override public void onBind(Target view, Value o, final OnBindListener onBindListener) { ObjectAnimator animatorX = ObjectAnimator.ofFloat(view, View.ROTATION, 0f, 10f); ObjectAnimator animatorY = ObjectAnimator.ofFloat(view, View.ROTATION_X, 0f, 90f); AnimatorSet set = new AnimatorSet(); set.setInterpolator(new AccelerateInterpolator(2f)); set.setDuration(300); set.setStartDelay(80 * count); set.playTogether(animatorX, animatorY); set.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); onBindListener.onBindDone(); } }); set.start(); count++; }
private void doStart(long delay) { ObjectAnimator topMaskAnimator = ObjectAnimator.ofFloat(topMaskView, "translationY", topMaskView.getTranslationY(), -halfHitBlockHeight); ObjectAnimator bottomMaskAnimator = ObjectAnimator.ofFloat(bottomMaskView, "translationY", bottomMaskView.getTranslationY(), halfHitBlockHeight); ObjectAnimator maskShadowAnimator = ObjectAnimator.ofFloat(maskReLayout, "alpha", maskReLayout.getAlpha(), 0); AnimatorSet animatorSet = new AnimatorSet(); animatorSet.play(topMaskAnimator).with(bottomMaskAnimator).with(maskShadowAnimator); animatorSet.setDuration(800); animatorSet.setStartDelay(delay); animatorSet.start(); animatorSet.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { topMaskView.setVisibility(View.GONE); bottomMaskView.setVisibility(View.GONE); maskReLayout.setVisibility(View.GONE); onGameStart(); } }); }
/** * Plays animations used by various transitions. */ private void playCommonTransitionAnimations( Workspace.State toWorkspaceState, boolean animated, boolean initialized, AnimatorSet animation, AnimationLayerSet layerViews) { // Create the workspace animation. // NOTE: this call apparently also sets the state for the workspace if !animated Animator workspaceAnim = mLauncher.startWorkspaceStateChangeAnimation(toWorkspaceState, animated, layerViews); if (animated && initialized) { // Play the workspace animation if (workspaceAnim != null) { animation.play(workspaceAnim); } } }
@TargetApi(Build.VERSION_CODES.LOLLIPOP) private void startUnreveal() { Animator animator = ViewAnimationUtils.createCircularReveal(previewChildView, getCenterX(previewChildView), getCenterY(previewChildView), getRadius(previewChildView), morphView.getWidth() * 2); animator.setTarget(previewChildView); animator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); previewChildView.animate().setListener(null); frameView.setVisibility(View.INVISIBLE); previewChildView.setVisibility(View.INVISIBLE); morphView.setVisibility(View.VISIBLE); morphView.animate() .y(getHideY()) .scaleY(0.5f) .scaleX(0.5f) .setDuration(UNMORPH_MOVE_DURATION) .setInterpolator(new AccelerateInterpolator()) .setListener(hideListener); } }); frameView.animate().alpha(1f).setDuration(UNMORPH_UNREVEAL_DURATION) .setInterpolator(new AccelerateInterpolator()); animator.setDuration(UNMORPH_UNREVEAL_DURATION) .setInterpolator(new AccelerateInterpolator()); animator.start(); }
@Override public View onCreateView(LayoutInflater inflater, ViewGroup viewGroup, Bundle bundle) { this.container = ViewUtil.inflate(inflater, viewGroup, R.layout.device_add_fragment); this.overlay = ViewUtil.findById(this.container, R.id.overlay); this.scannerView = ViewUtil.findById(this.container, R.id.scanner); this.devicesImage = ViewUtil.findById(this.container, R.id.devices); if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) { this.overlay.setOrientation(LinearLayout.HORIZONTAL); } else { this.overlay.setOrientation(LinearLayout.VERTICAL); } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { this.container.addOnLayoutChangeListener(new View.OnLayoutChangeListener() { @TargetApi(Build.VERSION_CODES.LOLLIPOP) @Override public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) { v.removeOnLayoutChangeListener(this); Animator reveal = ViewAnimationUtils.createCircularReveal(v, right, bottom, 0, (int) Math.hypot(right, bottom)); reveal.setInterpolator(new DecelerateInterpolator(2f)); reveal.setDuration(800); reveal.start(); } }); } return this.container; }
private boolean onItemLongClick(MessageObject item, View view, int a) { if (actionBar.isActionModeShowed()) { return false; } AndroidUtilities.hideKeyboard(getParentActivity().getCurrentFocus()); selectedFiles[item.getDialogId() == dialog_id ? 0 : 1].put(item.getId(), item); if (!item.canDeleteMessage(null)) { cantDeleteMessagesCount++; } actionBar.createActionMode().getItem(delete).setVisibility(cantDeleteMessagesCount == 0 ? View.VISIBLE : View.GONE); selectedMessagesCountTextView.setNumber(1, false); AnimatorSet animatorSet = new AnimatorSet(); ArrayList<Animator> animators = new ArrayList<>(); for (int i = 0; i < actionModeViews.size(); i++) { View view2 = actionModeViews.get(i); AndroidUtilities.clearDrawableAnimation(view2); animators.add(ObjectAnimator.ofFloat(view2, "scaleY", 0.1f, 1.0f)); } animatorSet.playTogether(animators); animatorSet.setDuration(250); animatorSet.start(); scrolling = false; if (view instanceof SharedDocumentCell) { ((SharedDocumentCell) view).setChecked(true, true); } else if (view instanceof SharedPhotoVideoCell) { ((SharedPhotoVideoCell) view).setChecked(a, true, true); } else if (view instanceof SharedLinkCell) { ((SharedLinkCell) view).setChecked(true, true); } actionBar.showActionMode(); return true; }
@Override public void animateTOMenu() { TransitionHelper.animateToMenuState(root, new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); bearsScene.setPause(false); } }); menuIcon.animateIconState(MaterialMenuDrawable.IconState.ARROW); hideShadow(); bearsScene.setPause(true); }
public AnimatedVectorDrawableCompatState(Context context, AnimatedVectorDrawableCompatState copy, Callback owner, Resources res) { if (copy != null) { this.mChangingConfigurations = copy.mChangingConfigurations; if (copy.mVectorDrawable != null) { ConstantState cs = copy.mVectorDrawable.getConstantState(); if (res != null) { this.mVectorDrawable = (VectorDrawableCompat) cs.newDrawable(res); } else { this.mVectorDrawable = (VectorDrawableCompat) cs.newDrawable(); } this.mVectorDrawable = (VectorDrawableCompat) this.mVectorDrawable.mutate(); this.mVectorDrawable.setCallback(owner); this.mVectorDrawable.setBounds(copy.mVectorDrawable.getBounds()); this.mVectorDrawable.setAllowCaching(false); } if (copy.mAnimators != null) { int numAnimators = copy.mAnimators.size(); this.mAnimators = new ArrayList(numAnimators); this.mTargetNameMap = new ArrayMap(numAnimators); for (int i = 0; i < numAnimators; i++) { Animator anim = (Animator) copy.mAnimators.get(i); Animator animClone = anim.clone(); String targetName = (String) copy.mTargetNameMap.get(anim); animClone.setTarget(this.mVectorDrawable.getTargetByName(targetName)); this.mAnimators.add(animClone); this.mTargetNameMap.put(animClone, targetName); } } } }
@Override public Animator getAnimationFor(AnimationBody animationBody, View view) { final AnimatorSet animatorSet = new AnimatorSet(); final ObjectAnimator translateAnimation = getTranslation(animationBody, view); final ObjectAnimator rotateAnimation = getRotation(view); animatorSet .play(translateAnimation) .with(rotateAnimation); return animatorSet; }
@Override public Animator createAnimator(ViewGroup sceneRoot, TransitionValues startValues, TransitionValues endValues) { if (endValues == null || startValues == null) { return null; } return RoundingImageTransitionHelper.createAnimator(endValues.view, startValues.values, endValues.values); }
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.cloneInContext(new ContextThemeWrapper(getContext(), getTheme())) .inflate(R.layout.fragment_side, container, false); final Bundle args = getArguments(); if (args != null) { rootView.addOnLayoutChangeListener(new View.OnLayoutChangeListener() { @Override public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) { v.removeOnLayoutChangeListener(this); int cx = args.getInt("cx"); int cy = args.getInt("cy"); // get the hypotheses so the mRadius is from one corner to the other float radius = (float) Math.hypot(right, bottom); // Hardware-supported clipPath() // http://developer.android.com/guide/topics/graphics/hardware-accel.html if (Build.VERSION.SDK_INT >= 18) { isAnimRunning = true; Animator reveal = createCheckoutRevealAnimator((ClipRevealFrame) v, cx, cy, 28f, radius); reveal.start(); } else { removeOldSideFragment(); } } }); } ButterKnife.bind(this, rootView); return rootView; }
@RequiresApi(api = Build.VERSION_CODES.HONEYCOMB) private void performDismiss() { // Animate the dismissed view to zero-height and then fire the dismiss callback. // This triggers layout on each animation frame; in the future we may want to do something // smarter and more performant. final ViewGroup.LayoutParams lp = mView.getLayoutParams(); final int originalHeight = mView.getHeight(); ValueAnimator animator = ValueAnimator.ofInt(originalHeight, 1).setDuration(mAnimationTime); animator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { mCallbacks.onDismiss(mView, mToken); // Reset view presentation mView.setAlpha(1f); mView.setTranslationX(0); lp.height = originalHeight; mView.setLayoutParams(lp); } }); animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator valueAnimator) { lp.height = (Integer) valueAnimator.getAnimatedValue(); mView.setLayoutParams(lp); } }); animator.start(); }
protected void startExitAnimation(final Animator.AnimatorListener animatorListener) { tooltipAnimation.animateExit(this, new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); animatorListener.onAnimationEnd(animation); if (listenerHide != null) { listenerHide.onHide(TooltipView.this); } } }); }
/** * Change card color. This method wraps the Property Animation API mentioned here * https://stackoverflow.com/a/14467625/7009268 */ public void animateFailedSet() { int colorFrom = ContextCompat.getColor(getContext(), R.color.card_background_normal); int colorTo = ContextCompat.getColor(getContext(), R.color.fbutton_color_carrot); final SetGameCardView card = this; int duration = getContext().getResources().getInteger(R.integer.card_fail_animation_duration_flash); ValueAnimator colorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), colorFrom, colorTo); colorAnimation.setDuration(duration); // milliseconds colorAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animator) { card.setCardBackgroundColor((int) animator.getAnimatedValue()); } }); colorAnimation.setRepeatMode(ValueAnimator.REVERSE); colorAnimation.setRepeatCount(2); colorAnimation.start(); colorAnimation.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { // Once animation is over, animate back to selected or highlighted or normal card.setChecked(false, false); if (isHighlighted()) { animateColorChange(R.color.fbutton_color_alizarin, R.color.card_background_highlighted); } else { animateColorChange(R.color.fbutton_color_alizarin, R.color.card_background_normal); } } }); }
/** * 由满向中间收缩,直到隐藏。 */ @SuppressLint("NewApi") public static void hide(final View myView, float endRadius, long durationMills) { if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.LOLLIPOP) { myView.setVisibility(View.INVISIBLE); return; } int cx = (myView.getLeft() + myView.getRight()) / 2; int cy = (myView.getTop() + myView.getBottom()) / 2; int w = myView.getWidth(); int h = myView.getHeight(); // 勾股定理 & 进一法 int initialRadius = (int) Math.sqrt(w * w + h * h) + 1; Animator anim = ViewAnimationUtils.createCircularReveal(myView, cx, cy, initialRadius, endRadius); anim.setDuration(durationMills); anim.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); myView.setVisibility(View.INVISIBLE); } }); anim.start(); }
@Override public Animator onAppear(ViewGroup sceneRoot, final View view, TransitionValues startValues, TransitionValues endValues) { Animator reveal = ViewAnimationUtils.createCircularReveal(view, 140, 200, 0, 1000); return new NoPauseAnimator(reveal); }
/** * 4.加载更多完成或者不满足进入加载更多模式的条件时,收起尾部(当前位置 ~ 0) */ public void animBottomBack() { isAnimBottomBack = true; animLayoutByTime(getVisibleFootHeight(), 0, animBottomUpListener, new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { isAnimBottomBack = false; } }); }
private void close() { mBtnPub.clearAnimation(); mBtnPub.animate() .rotation(0f) .setDuration(180) .setListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); finish(); } }) .start(); }
private Animator createRevealAnimator(FloatingActionButton dot, float offsetY){ ViewCompat.setElevation(dot,0); dot.setVisibility(View.INVISIBLE); lastDot=dot; int cx=(int)(dot.getX()+dot.getHeight()/2); int cy=(int)(dot.getY()+dot.getHeight()/2+offsetY); int w = topPanel.getWidth(); int h = topPanel.getHeight(); final int endRadius = !isFolded?(int) Math.hypot(w, h):dot.getHeight()/2; final int startRadius=isFolded?(int) Math.hypot(w, h):dot.getHeight()/2; topPanel.setVisibility(View.VISIBLE); Animator animator= ViewAnimationUtils.createCircularReveal(topPanel,cx,cy,startRadius,endRadius); animator.setDuration(duration(R.integer.reveal_duration)); return animator; }
/** * 创建回弹动画 * 上圆半径减速恢复至最大半径 * 下圆半径减速恢复至最大半径 * 圆心距减速从最大值减到0(下圆Y从当前位置移动到上圆Y)。 */ public Animator createAnimator() { ValueAnimator valueAnimator = ValueAnimator.ofFloat(1, 0.001f).setDuration(BACK_ANIM_DURATION); valueAnimator.setInterpolator(new DecelerateInterpolator()); valueAnimator.addUpdateListener(valueAnimator1 -> { updateComleteState((float) valueAnimator1.getAnimatedValue()); postInvalidate(); }); return valueAnimator; }
@Override public Animator[] getAnimators(View view) { return new Animator[]{ ObjectAnimator.ofFloat(view, "translationX", -view.getRootView().getWidth(), 0) }; }
private void startAnimation(){ int cx = rootLayout.getWidth() / 2; int cy = rootLayout.getHeight() / 2; float finalRadius = (float) Math.hypot(cx, cy); Animator anim = ViewAnimationUtils.createCircularReveal(rootLayout, cx, cy, 0f, finalRadius); anim.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); } }); rootLayout.setVisibility(View.VISIBLE); anim.start(); }