List of usage examples for android.animation AnimatorSet AnimatorSet
public AnimatorSet()
From source file:com.itsronald.widget.IndicatorDotPathView.java
@NonNull Animator connectPathAnimator() {//from w w w . j a v a 2 s . co m final Rect startSegmentBounds = viewRectInNeighborCoords(startPathSegment, endPathSegment); final Rect endSegmentBounds = viewRectInNeighborCoords(endPathSegment, startPathSegment); final int startSegmentToX = endSegmentBounds.centerX() < 0 ? endSegmentBounds.left : endSegmentBounds.right; final int startSegmentToY = endSegmentBounds.centerY() < 0 ? endSegmentBounds.top : endSegmentBounds.bottom; final int endSegmentToX = startSegmentBounds.centerX() < 0 ? startSegmentBounds.left : startSegmentBounds.right; final int endSegmentToY = startSegmentBounds.centerY() < 0 ? startSegmentBounds.top : startSegmentBounds.bottom; final Animator startSegmentAnimator = startPathSegment.stretchAnimator(PATH_STRETCH_ANIM_DURATION, startSegmentToX, startSegmentToY); final Animator endSegmentAnimator = endPathSegment.stretchAnimator(PATH_STRETCH_ANIM_DURATION, endSegmentToX, endSegmentToY); final AnimatorSet animatorSet = new AnimatorSet(); animatorSet.playTogether(startSegmentAnimator, endSegmentAnimator, centerSegmentGrowAnimator()); animatorSet.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animation) { startDot.setVisibility(VISIBLE); endDot.setVisibility(VISIBLE); } }); return animatorSet; }
From source file:com.google.samples.apps.topeka.view.quiz.QuizActivity.java
@TargetApi(Build.VERSION_CODES.LOLLIPOP) private void revealFragmentContainerLollipop(final View clickedView, final FrameLayout fragmentContainer, int themeAccentColor) { prepareCircularReveal(clickedView, fragmentContainer, themeAccentColor); ViewCompat.animate(clickedView).scaleX(0).scaleY(0).alpha(0).setInterpolator(mInterpolator) .setListener(new ViewPropertyAnimatorListenerAdapter() { @Override//w w w . j a v a2s . c o m public void onAnimationEnd(View view) { fragmentContainer.setVisibility(View.VISIBLE); clickedView.setVisibility(View.GONE); } }).start(); fragmentContainer.setVisibility(View.VISIBLE); AnimatorSet animatorSet = new AnimatorSet(); animatorSet.play(mCircularReveal).with(mColorChange); animatorSet.start(); }
From source file:de.dreier.mytargets.shared.views.TargetViewBase.java
protected void playAnimations(List<Animator> setList) { cancelPendingAnimations();/*from w w w . j av a 2 s. c o m*/ animator = new AnimatorSet(); animator.playTogether(setList); animator.setInterpolator(new AccelerateDecelerateInterpolator()); animator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationCancel(Animator animation) { onAnimationEnd(animation); } @Override public void onAnimationEnd(Animator animation) { animator = null; updateVirtualViews(); invalidate(); } }); animator.setDuration(300); animator.start(); }
From source file:com.evilduck.animtest.DraggedPanelLayout.java
public void animatePanel(final boolean opening, float distY, long duration) { ObjectAnimator slidingPanelAnimator = ObjectAnimator.ofFloat(slidingPanel, View.TRANSLATION_Y, slidingPanel.getTranslationY(), slidingPanel.getTranslationY() + distY); ObjectAnimator bottomPanelAnimator = ObjectAnimator.ofFloat(bottomPanel, View.TRANSLATION_Y, bottomPanel.getTranslationY(), bottomPanel.getTranslationY() + (float) (distY * parallaxFactor)); AnimatorSet set = new AnimatorSet(); set.playTogether(slidingPanelAnimator, bottomPanelAnimator); set.setDuration(duration);//from ww w.ja v a2 s .co m set.setInterpolator(sDecelerator); set.addListener(new MyAnimListener(opening)); set.start(); }
From source file:la.marsave.fullscreentest.MainActivity.java
/** * This method animates the image fragment into the foreground by both * scaling and rotating the fragment's view, while also removing the * previously added translucent dark hover view. Upon the completion of * this animation, the image fragment regains focus since this method is * called from the onBackStackChanged method. *///from w w w. ja v a 2 s . c om public void slideForward() { View movingFragmentView = mInfiniteViewPager; PropertyValuesHolder rotateX = PropertyValuesHolder.ofFloat("rotationX", 40f); PropertyValuesHolder scaleX = PropertyValuesHolder.ofFloat("scaleX", 1.0f); PropertyValuesHolder scaleY = PropertyValuesHolder.ofFloat("scaleY", 1.0f); ObjectAnimator movingFragmentAnimator = ObjectAnimator.ofPropertyValuesHolder(movingFragmentView, rotateX, scaleX, scaleY); ObjectAnimator darkHoverViewAnimator = ObjectAnimator.ofFloat(mDarkHoverView, "alpha", 0.5f, 0.0f); ObjectAnimator movingFragmentRotator = ObjectAnimator.ofFloat(movingFragmentView, "rotationX", 0); movingFragmentRotator.setStartDelay(getResources().getInteger(R.integer.half_slide_up_down_duration)); AnimatorSet s = new AnimatorSet(); s.playTogether(movingFragmentAnimator, movingFragmentRotator, darkHoverViewAnimator); s.setStartDelay(getResources().getInteger(R.integer.slide_up_down_duration)); s.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { mIsAnimating = false; } }); s.start(); }
From source file:com.ibm.mil.readyapps.physio.fragments.LandingFragment.java
private void animateMetricsOut(boolean isInitial) { int delay = 0; if (isInitial) { delay = INIT_DELAY;//from w w w .ja v a 2 s. co m } ObjectAnimator weightSlideOutAnimator = ObjectAnimator.ofFloat(weightTab, "translationX", 1f + SLIDE_OFFSET); ObjectAnimator heartRateSlideOutAnimator = ObjectAnimator.ofFloat(heartRateTab, "translationX", 1f + SLIDE_OFFSET); ObjectAnimator stepsSlideOutAnimator = ObjectAnimator.ofFloat(stepsTab, "translationX", 1f + SLIDE_OFFSET); heartRateSlideOutAnimator.setDuration(ANIM_SPEED * 2); heartRateSlideOutAnimator.setStartDelay(ANIM_SPEED * 2); weightSlideOutAnimator.setDuration(ANIM_SPEED * 2); weightSlideOutAnimator.setStartDelay(delay); stepsSlideOutAnimator.setDuration(ANIM_SPEED * 2); stepsSlideOutAnimator.setStartDelay(ANIM_SPEED); AnimatorSet outAnimation = new AnimatorSet(); outAnimation.play(weightSlideOutAnimator).with(stepsSlideOutAnimator).with(heartRateSlideOutAnimator); outAnimation.start(); }
From source file:com.google.android.apps.gutenberg.ScannerActivity.java
private void showCheckinAnimation(Checkin checkin) { if (mLastAnimator != null) { mLastAnimator.cancel();//from w w w. j av a 2 s . c om } final FrameLayout cover = (FrameLayout) findViewById(R.id.item_cover); cover.setVisibility(View.VISIBLE); final FrameLayout layer = (FrameLayout) findViewById(R.id.animation_layer); final CheckinHolder holder = new CheckinHolder(getLayoutInflater(), layer); FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.WRAP_CONTENT); lp.gravity = Gravity.CENTER_VERTICAL; holder.setWillAnimate(true); holder.bind(checkin, mImageLoader); holder.itemView.setBackgroundColor(Color.rgb(0xf0, 0xf0, 0xf0)); float elevation = getResources().getDimension(R.dimen.popup_elevation); ViewCompat.setTranslationZ(holder.itemView, elevation); holder.setLines(false, false); layer.addView(holder.itemView, lp); // Interpolator for animators FastOutSlowInInterpolator interpolator = new FastOutSlowInInterpolator(); // Pop-up Animator popUpAnim = AnimatorInflater.loadAnimator(this, R.animator.pop_up); popUpAnim.setTarget(holder.itemView); popUpAnim.setInterpolator(interpolator); popUpAnim.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { holder.animateCheckin(); } }); // Wait ObjectAnimator waitAnim = new ObjectAnimator(); waitAnim.setTarget(holder.itemView); waitAnim.setPropertyName("translationY"); waitAnim.setFloatValues(0.f, 0.f); waitAnim.setDuration(2000); // Slide-down ObjectAnimator slideDownAnim = new ObjectAnimator(); slideDownAnim.setTarget(holder.itemView); slideDownAnim.setPropertyName("translationY"); slideDownAnim.setFloatValues(0.f, calcSlideDistance()); slideDownAnim.setInterpolator(interpolator); // Landing anim ObjectAnimator landingAnim = new ObjectAnimator(); landingAnim.setTarget(holder.itemView); landingAnim.setPropertyName("translationZ"); landingAnim.setFloatValues(elevation, 0.f); landingAnim.setInterpolator(interpolator); landingAnim.setDuration(500); // Play the animators AnimatorSet set = new AnimatorSet(); set.setInterpolator(interpolator); set.playSequentially(popUpAnim, waitAnim, slideDownAnim, landingAnim); set.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { clean(); } @Override public void onAnimationCancel(Animator animation) { clean(); } private void clean() { mLastAnimator = null; layer.removeAllViews(); cover.setVisibility(View.INVISIBLE); } }); mLastAnimator = set; set.start(); }
From source file:com.hamzahrmalik.calculator2.Calculator.java
@Override public void onTextSizeChanged(final TextView textView, float oldSize) { if (mCurrentState != CalculatorState.INPUT) { // Only animate text changes that occur from user input. return;//from w ww . j av a 2 s.c o m } // Calculate the values needed to perform the scale and translation // animations, // maintaining the same apparent baseline for the displayed text. final float textScale = oldSize / textView.getTextSize(); final float translationX = (1.0f - textScale) * (textView.getWidth() / 2.0f - textView.getPaddingEnd()); final float translationY = (1.0f - textScale) * (textView.getHeight() / 2.0f - textView.getPaddingBottom()); final AnimatorSet animatorSet = new AnimatorSet(); animatorSet.playTogether(ObjectAnimator.ofFloat(textView, View.SCALE_X, textScale, 1.0f), ObjectAnimator.ofFloat(textView, View.SCALE_Y, textScale, 1.0f), ObjectAnimator.ofFloat(textView, View.TRANSLATION_X, translationX, 0.0f), ObjectAnimator.ofFloat(textView, View.TRANSLATION_Y, translationY, 0.0f)); animatorSet.setDuration(getResources().getInteger(android.R.integer.config_mediumAnimTime)); animatorSet.setInterpolator(new AccelerateDecelerateInterpolator()); animatorSet.start(); }
From source file:com.andremion.floatingnavigationview.FloatingNavigationView.java
private void startOpenAnimations() { // Icon/*www.j a v a 2 s .com*/ // Animated Icons AnimatedVectorDrawable menuIcon = (AnimatedVectorDrawable) ContextCompat.getDrawable(getContext(), R.drawable.ic_menu_animated); mFabView.setImageDrawable(menuIcon); menuIcon.start(); // Reveal int centerX = mFabRect.centerX(); int centerY = mFabRect.centerY(); float startRadius = getMinRadius(); float endRadius = getMaxRadius(); Animator reveal = ViewAnimationUtils.createCircularReveal(mNavigationView, centerX, centerY, startRadius, endRadius); // Fade in mNavigationMenuView.setAlpha(0); Animator fade = ObjectAnimator.ofFloat(mNavigationMenuView, View.ALPHA, 0, 1); // Animations AnimatorSet set = new AnimatorSet(); set.playSequentially(reveal, fade); set.start(); }
From source file:ch.gianulli.flashcards.ui.Flashcard.java
public void turnCard() { if (mPreviousAnimation != null) { mPreviousAnimation.cancel();//from w ww . ja v a 2 s . co m mPreviousAnimation = null; } AnimatorSet set = new AnimatorSet(); mQuestion.setLayerType(View.LAYER_TYPE_HARDWARE, null); mAnswer.setLayerType(View.LAYER_TYPE_HARDWARE, null); if (mQuestionShowing) { mQuestionShowing = false; mQuestion.setVisibility(View.VISIBLE); mQuestion.setAlpha(1.0f); mAnswer.setVisibility(View.VISIBLE); mAnswer.setAlpha(0.0f); ObjectAnimator questionAnim = ObjectAnimator.ofFloat(mQuestion, "alpha", 1.0f, 0.0f); questionAnim.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { mQuestion.setVisibility(View.GONE); } }); ObjectAnimator answerAnim = ObjectAnimator.ofFloat(mAnswer, "alpha", 0.0f, 1.0f); set.playTogether(questionAnim, answerAnim); // Show button bar if necessary if (!mButtonBarShowing) { expandButtonBar(); } } else { mQuestionShowing = true; mQuestion.setVisibility(View.VISIBLE); mQuestion.setAlpha(0.0f); mAnswer.setVisibility(View.VISIBLE); mAnswer.setAlpha(1.0f); ObjectAnimator questionAnim = ObjectAnimator.ofFloat(mQuestion, "alpha", 0.0f, 1.0f); ObjectAnimator answerAnim = ObjectAnimator.ofFloat(mAnswer, "alpha", 1.0f, 0.0f); answerAnim.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { mAnswer.setVisibility(View.GONE); } }); set.playTogether(questionAnim, answerAnim); } set.setDuration(400); mPreviousAnimation = set; set.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { mQuestion.setLayerType(View.LAYER_TYPE_SOFTWARE, null); mAnswer.setLayerType(View.LAYER_TYPE_SOFTWARE, null); mPreviousAnimation = null; } }); set.start(); }