android.animation.Animator Java Examples
The following examples show how to use
android.animation.Animator.
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: EmptyBackgroundViewTablet.java From 365browser with Apache License 2.0 | 6 votes |
public void setEmptyContainerState(boolean shouldShow) { Animator nextAnimator = null; if (shouldShow && getVisibility() != View.VISIBLE && mCurrentTransitionAnimation != mAnimateInAnimation) { nextAnimator = mAnimateInAnimation; UiUtils.hideKeyboard(this); } else if (!shouldShow && getVisibility() != View.GONE && mCurrentTransitionAnimation != mAnimateOutAnimation) { nextAnimator = mAnimateOutAnimation; } if (nextAnimator != null) { if (mCurrentTransitionAnimation != null) mCurrentTransitionAnimation.cancel(); mCurrentTransitionAnimation = nextAnimator; mCurrentTransitionAnimation.start(); } }
Example #2
Source File: AnimatorsCompat.java From Carbon with Apache License 2.0 | 6 votes |
public static void setAutoCancel(final ObjectAnimator animator) { animator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animation) { for (WeakReference<ObjectAnimator> wa : sRunningAnimators) { ObjectAnimator a = wa.get(); if (a == null) { continue; } if (hasSameTargetAndProperties(animator, a)) { a.cancel(); } } } }); }
Example #3
Source File: ContainersLayout.java From MaterialMasterDetail with Apache License 2.0 | 6 votes |
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(); } }); }
Example #4
Source File: MainActivity.java From mirror with GNU General Public License v3.0 | 6 votes |
@Override public void onDragDismiss(final ArtboardView view, boolean isDragDown) { mIsDragDismiss = true; switchToArtboardListView(); view.animate().alpha(0.0F) .translationY(isDragDown ? -view.getHeight() : view.getHeight()) .setDuration(AnimUtils.DURATION) .setInterpolator(new AccelerateInterpolator()) .setListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animator) { mIsDragDismiss = false; mArtboardPagerView.getBackground().mutate().setAlpha(255); view.setTranslationY(0.0F); view.setAlpha(1.0F); } }) .start(); }
Example #5
Source File: CircularAnimUtil.java From SeeWeather with Apache License 2.0 | 6 votes |
/** * 向四周伸张,直到完成显示。 */ @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(); }
Example #6
Source File: AnimateCounter.java From PlayLikeCurl with MIT License | 6 votes |
/** * Call to execute the animation */ public void execute(){ mValueAnimator = ValueAnimator.ofFloat(mStartValue, mEndValue); mValueAnimator.setDuration(mDuration); mValueAnimator.setInterpolator(mInterpolator); mValueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator valueAnimator) { float current = Float.valueOf(valueAnimator.getAnimatedValue().toString()); if(mListener!=null)mListener.onValueUpdate(current); // mView.setText(String.format("%." + mPrecision + "f", current)); } }); mValueAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { if (mListener != null) { mListener.onAnimateCounterEnd(); } } }); mValueAnimator.start(); }
Example #7
Source File: CalendarLayout.java From ShizuruNotes with Apache License 2.0 | 6 votes |
/** * 显示内容布局 */ @SuppressLint("NewApi") final void showContentView() { if (mContentView == null) return; mContentView.setTranslationY(getHeight() - mMonthView.getHeight()); mContentView.setVisibility(VISIBLE); mContentView.animate() .translationY(0) .setDuration(180) .setInterpolator(new LinearInterpolator()) .setListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); } }); }
Example #8
Source File: ShareView.java From ChinaShare with MIT License | 6 votes |
private void shareViewTranslationAnimator(final float start, final float end) { if (Build.VERSION.SDK_INT >= 11) { ObjectAnimator bottomAnim = ObjectAnimator.ofFloat(llContent, "translationY", start, end); bottomAnim.setDuration(duration); bottomAnim.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); if (start < end) {//close ShareView shareView.setVisibility(View.GONE); } else {//show ShareView } } }); bottomAnim.start(); } }
Example #9
Source File: BaseDialogFragment.java From natrium-android-wallet with BSD 2-Clause "Simplified" License | 6 votes |
/** * Animate appearance of a view * * @param view View to animate * @param toVisibility Visibility at the end of animation * @param toAlpha Alpha at the end of animation * @param duration Animation duration in ms */ public static void animateView(final View view, final int toVisibility, float toAlpha, int duration) { boolean show = toVisibility == View.VISIBLE; if (show) { view.setAlpha(0); } view.setVisibility(View.VISIBLE); view.animate() .setDuration(duration) .alpha(show ? toAlpha : 0) .setListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { view.setVisibility(toVisibility); } }); }
Example #10
Source File: PersonFragment.java From Melophile with Apache License 2.0 | 6 votes |
@Override public void hideLoading() { progress.animate() .scaleX(0) .scaleY(0) .setDuration(300) .setListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); //if the animation is still running when the back button has been pressed if (progress != null) { progress.setVisibility(View.GONE); } } }).start(); }
Example #11
Source File: ShimmerLayout.java From ShimmerLayout with Apache License 2.0 | 6 votes |
public void startShimmerAnimation() { if (isAnimationStarted) { return; } if (getWidth() == 0) { startAnimationPreDrawListener = new ViewTreeObserver.OnPreDrawListener() { @Override public boolean onPreDraw() { getViewTreeObserver().removeOnPreDrawListener(this); startShimmerAnimation(); return true; } }; getViewTreeObserver().addOnPreDrawListener(startAnimationPreDrawListener); return; } Animator animator = getShimmerAnimation(); animator.start(); isAnimationStarted = true; }
Example #12
Source File: CategoryPropertyEditor.java From edslite with GNU General Public License v2.0 | 6 votes |
private void rotateIconAndChangeState() { IS_ANIMATING = true; _indicatorIcon.clearAnimation(); ObjectAnimator anim = ObjectAnimator.ofFloat(_indicatorIcon, View.ROTATION, _isExpanded ? 0 : 180); anim.setDuration(200); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) _indicatorIcon.setHasTransientState(true); anim.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { if(_isExpanded) collapse(); else expand(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) _indicatorIcon.setHasTransientState(false); IS_ANIMATING = false; } }); anim.start(); }
Example #13
Source File: ToolbarPhone.java From 365browser with Apache License 2.0 | 6 votes |
private ObjectAnimator createExitTabSwitcherAnimation( final boolean animateNormalToolbar) { ObjectAnimator exitAnimation = ObjectAnimator.ofFloat(this, mTabSwitcherModePercentProperty, 0.f); exitAnimation.setDuration(animateNormalToolbar ? TAB_SWITCHER_MODE_EXIT_NORMAL_ANIMATION_DURATION_MS : TAB_SWITCHER_MODE_EXIT_FADE_ANIMATION_DURATION_MS); exitAnimation.setInterpolator(new LinearInterpolator()); exitAnimation.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { updateViewsForTabSwitcherMode(); } }); return exitAnimation; }
Example #14
Source File: NotificationView.java From Android-Notification with Apache License 2.0 | 6 votes |
/** * Rotate the contentView to x degree with animation. * * @param degree * @param alpha * @param listener * @param duration */ public void animateContentViewRotationX(float degree, float alpha, Animator.AnimatorListener listener, int duration) { if (DBG) Log.v(TAG, "animateContentViewRotationX - " + "degree=" + degree + ", alpha=" + alpha); mContentView.animate().cancel(); mContentView.animate() .alpha(alpha) .rotationX(degree) .setListener(listener) .setDuration(duration) .start(); }
Example #15
Source File: MapSearchView.java From droidkaigi2016 with Apache License 2.0 | 6 votes |
private void revealOn() { if (binding.mapListContainer.getVisibility() == VISIBLE) return; View container = binding.mapListContainer; Animator animator = ViewAnimationUtils.createCircularReveal( container, getRevealCenterX(container), container.getTop(), 0, (float) Math.hypot(container.getWidth(), container.getHeight())); animator.setInterpolator(INTERPOLATOR); animator.setDuration(getResources().getInteger(R.integer.view_reveal_mills)); animator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animation) { binding.mapListContainer.setVisibility(VISIBLE); if (onVisibilityChangeListener != null) { onVisibilityChangeListener.onChange(); } } }); animator.start(); }
Example #16
Source File: BalloonMarker.java From Genius-Android with Apache License 2.0 | 5 votes |
@TargetApi(Build.VERSION_CODES.JELLY_BEAN) public void animateClose() { mBalloonMarkerDrawable.stop(); ViewPropertyAnimator animator = mNumber.animate(); animator.alpha(0f); animator.setDuration(100); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { animator.withEndAction(new Runnable() { @Override public void run() { //We use INVISIBLE instead of GONE to avoid a requestLayout mNumber.setVisibility(View.INVISIBLE); mBalloonMarkerDrawable.animateToNormal(); } }); } else { animator.setListener(new AnimatorListener() { @Override public void onAnimationEnd(Animator animation) { //We use INVISIBLE instead of GONE to avoid a requestLayout mNumber.setVisibility(View.INVISIBLE); mBalloonMarkerDrawable.animateToNormal(); } }); } animator.start(); }
Example #17
Source File: FloatingNavigationView.java From Floating-Navigation-View with Apache License 2.0 | 5 votes |
private void startCloseAnimations() { // Icon AnimatedVectorDrawableCompat closeIcon = AnimatedVectorDrawableCompat.create(getContext(), R.drawable.ic_close_animated); mFabView.setImageDrawable(closeIcon); closeIcon.start(); // Unreveal int centerX = mFabRect.centerX(); int centerY = mFabRect.centerY(); float startRadius = getMaxRadius(); float endRadius = getMinRadius(); Animator reveal = CircularRevealCompat.createCircularReveal( mNavigationView, centerX, centerY, startRadius, endRadius ); reveal.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { detachNavigationView(); } }); // Fade out Animator fade = ObjectAnimator.ofFloat(mNavigationMenuView, View.ALPHA, 1, 0); // Animations AnimatorSet set = new AnimatorSet(); set.playTogether(fade, reveal); set.start(); }
Example #18
Source File: YoYo.java From KUtils-master with Apache License 2.0 | 5 votes |
private BaseViewAnimator play() { animator.setTarget(target); if (pivotX == YoYo.CENTER_PIVOT) { ViewCompat.setPivotX(target, target.getMeasuredWidth() / 2.0f); } else { target.setPivotX(pivotX); } if (pivotY == YoYo.CENTER_PIVOT) { ViewCompat.setPivotY(target, target.getMeasuredHeight() / 2.0f); } else { target.setPivotY(pivotY); } animator.setDuration(duration) .setRepeatTimes(repeatTimes) .setRepeatMode(repeatMode) .setInterpolator(interpolator) .setStartDelay(delay); if (callbacks.size() > 0) { for (Animator.AnimatorListener callback : callbacks) { animator.addAnimatorListener(callback); } } animator.animate(); return animator; }
Example #19
Source File: InterruptibleInOutAnimator.java From TurboLauncher with Apache License 2.0 | 5 votes |
public InterruptibleInOutAnimator(View view, long duration, float fromValue, float toValue) { mAnimator = LauncherAnimUtils.ofFloat(view, fromValue, toValue).setDuration(duration); mOriginalDuration = duration; mOriginalFromValue = fromValue; mOriginalToValue = toValue; mAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { mDirection = STOPPED; } }); }
Example #20
Source File: SearchPlaceActivity.java From Expert-Android-Programming with MIT License | 5 votes |
private void showTop(View view) { view.setVisibility(View.VISIBLE); Animator iconAnim = ObjectAnimator.ofPropertyValuesHolder(view, PropertyValuesHolder.ofFloat(View.TRANSLATION_Y, -view.getHeight(), 0f)); iconAnim.setDuration(VIEW_ANIMATION); iconAnim.start(); }
Example #21
Source File: BaseCircleIndicator.java From CircleIndicator with Apache License 2.0 | 5 votes |
protected Animator createAnimatorIn(Config config) { Animator animatorIn; if (config.animatorReverseResId == 0) { animatorIn = AnimatorInflater.loadAnimator(getContext(), config.animatorResId); animatorIn.setInterpolator(new ReverseInterpolator()); } else { animatorIn = AnimatorInflater.loadAnimator(getContext(), config.animatorReverseResId); } return animatorIn; }
Example #22
Source File: DialogRadioCell.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
public void setEnabled(boolean value, ArrayList<Animator> animators) { if (animators != null) { animators.add(ObjectAnimator.ofFloat(textView, "alpha", value ? 1.0f : 0.5f)); animators.add(ObjectAnimator.ofFloat(radioButton, "alpha", value ? 1.0f : 0.5f)); } else { textView.setAlpha(value ? 1.0f : 0.5f); radioButton.setAlpha(value ? 1.0f : 0.5f); } }
Example #23
Source File: RecyclerView.java From Carbon with Apache License 2.0 | 5 votes |
public void setOutAnimator(Animator outAnim) { if (this.outAnim != null) this.outAnim.setTarget(null); this.outAnim = outAnim; if (outAnim != null) outAnim.setTarget(this); }
Example #24
Source File: ActionAnimatorSet.java From ActionAnimatorSet with GNU General Public License v3.0 | 5 votes |
Builder between(Animator anim, TriggerPoint startPoint) { AnimNode node = mNodeMap.get(anim); if (node == null) { //记录一下依赖关系,待会添加 mTmpDep.put(anim, this); mCurrentRule = AnimNode.BETWEEN; mStartPoint = startPoint; return this; } node.rule = AnimNode.BETWEEN; node.addDependency(mCurrentNode, AnimNode.BETWEEN); mCurrentNode.startPoint = startPoint; mCurrentNode.addToDependency(node); return this; }
Example #25
Source File: QuestionsFragment.java From ifican with Apache License 2.0 | 5 votes |
private void animateOut() { text1.setVisibility(View.GONE); container2.setVisibility(View.VISIBLE); container2.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() { @Override public boolean onPreDraw() { container2.getViewTreeObserver().removeOnPreDrawListener(this); ViewPropertyAnimator animator = animateViewsOut(); animator.setListener(new SimpleAnimatorListener() { @Override public void onAnimationEnd(Animator animation) { container2.setVisibility(View.GONE); animateAlpha(); } }); animator.start(); container3.animate().alpha(1f).setDuration(300).setStartDelay(600).start(); ObjectAnimator background = ObjectAnimator.ofObject(container, "backgroundColor", new ArgbEvaluator(), yellow, green); background.setDuration(300); background.setStartDelay(600); background.start(); return false; } }); }
Example #26
Source File: ViewAnim.java From nono-android with GNU General Public License v3.0 | 5 votes |
@Override public void onAnimationCancel(Animator animator) { // TODO 自动生成的方法存根 if (mListener != null) { mListener.onViewAnimationCancel(mFromView, animator); } }
Example #27
Source File: ViewAnimationUtils.java From EhViewer with Apache License 2.0 | 5 votes |
@TargetApi(Build.VERSION_CODES.LOLLIPOP) public static Animator createCircularReveal(View view, int centerX, int centerY, float startRadius, float endRadius) { if (API_SUPPORT_CIRCULAR_REVEAL) { return android.view.ViewAnimationUtils.createCircularReveal( view, centerX, centerY, startRadius, endRadius); } else if (view instanceof Reveal){ return createRevealAnimator((Reveal) view, centerX, centerY, startRadius, endRadius); } else { throw new IllegalStateException("Only View implements CircularReveal or" + " api >= 21 can create circular reveal"); } }
Example #28
Source File: BaseIndicatorController.java From LRecyclerView with Apache License 2.0 | 5 votes |
/** * make animation to start or end when target * view was be Visible or Gone or Invisible. * make animation to cancel when target view * be onDetachedFromWindow. * @param animStatus */ public void setAnimationStatus(AnimStatus animStatus){ if (mAnimators==null){ return; } int count=mAnimators.size(); for (int i = 0; i < count; i++) { Animator animator=mAnimators.get(i); boolean isRunning=animator.isRunning(); switch (animStatus){ case START: if (!isRunning){ animator.start(); } break; case END: if (isRunning){ animator.end(); } break; case CANCEL: if (isRunning){ animator.cancel(); } break; } } }
Example #29
Source File: WorldController.java From tilt-game-android with MIT License | 5 votes |
public void playLevelEndAnimation() { Vector2 destPos = _gameLevel.getSinkholeLocation(); // if level doesn't have a sink, don't bother with the animation if (_ballSprite == null || destPos == null) { _gameLevelStateListener.onOutAnimationComplete(); return; } _isAnimating = true; long duration = 200; ObjectAnimator.ofFloat(_ballSprite, "x", destPos.x).setDuration(duration).start(); ObjectAnimator animator = ObjectAnimator.ofFloat(_ballSprite, "y", destPos.y).setDuration(duration); animator.start(); animator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { _ballSprite.hide(100); _sinkHole.hide(200, null); _sinkHoleBorder.hide(300, new AnimationCallback() { @Override public void onComplete() { if (_gameLevelStateListener != null) { _gameLevelStateListener.onOutAnimationComplete(); } _isAnimating = false; } }); } }); }
Example #30
Source File: AnimatedDoorActivity.java From UltimateAndroid with Apache License 2.0 | 5 votes |
@Override public void onBackPressed() { ObjectAnimator animator = ObjectAnimator.ofFloat(mAnimated, ANIMATED_DOOR_LAYOUT_FLOAT_PROPERTY, 0).setDuration(600); animator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { finish(); } }); animator.start(); }