List of usage examples for android.animation ObjectAnimator ofFloat
public static <T> ObjectAnimator ofFloat(T target, Property<T, Float> xProperty, Property<T, Float> yProperty, Path path)
Path
using two properties. 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 w w . j a v a 2s. co 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:ch.gianulli.flashcards.ui.Flashcard.java
public void turnCard() { if (mPreviousAnimation != null) { mPreviousAnimation.cancel();/*w w w .j ava 2 s.c o 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(); }
From source file:com.github.jokar.rxupload.widget.ProgressDownloadView.java
public void setPercentage(float newProgress) { if (newProgress < 0 || newProgress > 100) { throw new IllegalArgumentException("setPercentage not between 0 and 100"); }//from www . ja v a2 s . co m mState = State.STATE_WORKING; mTarget = newProgress; ObjectAnimator anim = ObjectAnimator.ofFloat(this, "progress", getProgress(), mTarget); anim.setInterpolator(new DecelerateInterpolator()); anim.setDuration((long) (ANIMATION_DURATION_BASE + Math.abs(mTarget * 10 - getProgress() * 10) / 2)); anim.start(); }
From source file:com.itsronald.widget.IndicatorDotPathView.java
/** * Animation: fill out the connecting center dot path to form a straight path between the two * dots./*from w w w .j av a2 s . c om*/ * * @return An animator that grows pathCenter to the appropriate height. */ @NonNull private Animator centerSegmentGrowAnimator() { final float fromScale = 0f, toScale = 1f; final ObjectAnimator growAnimator; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { final PropertyValuesHolder scaleYProperty = PropertyValuesHolder.ofFloat(View.SCALE_Y, fromScale, toScale); growAnimator = ObjectAnimator.ofPropertyValuesHolder(centerSegment, scaleYProperty); } else { growAnimator = ObjectAnimator.ofFloat(centerSegment, "scaleY", fromScale, toScale); } // Start growing when the two ends of the path meet in the middle. final long animationDuration = PATH_STRETCH_ANIM_DURATION / 4; growAnimator.setStartDelay(animationDuration); growAnimator.setDuration(animationDuration); growAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animation) { super.onAnimationStart(animation); centerSegment.setVisibility(VISIBLE); } }); return growAnimator; }
From source file:com.andremion.floatingnavigationview.FloatingNavigationView.java
private void startCloseAnimations() { // Icon/*www . java2 s . com*/ AnimatedVectorDrawable closeIcon = (AnimatedVectorDrawable) ContextCompat.getDrawable(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 = ViewAnimationUtils.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(); }
From source file:com.example.george.sharedelementimplementation.MainActivity.java
public void runExitAnimation() { final long duration = (long) (ANIM_DURATION * MainActivity.sAnimatorScale); ObjectAnimator anim = ObjectAnimator.ofInt(mBackground, "alpha", 0); anim.addListener(new Animator.AnimatorListener() { @Override/* w ww . java 2s . c o m*/ public void onAnimationStart(Animator animation) { // do nothing intended } @Override public void onAnimationEnd(Animator animation) { mIsInFullscreen = false; mIsAnimationPlaying = false; mImage.setVisibility(View.GONE); } @Override public void onAnimationCancel(Animator animation) { // do nothing intended } @Override public void onAnimationRepeat(Animator animation) { // do nothing intended } }); AnimatorSet set = new AnimatorSet(); set.playTogether(ObjectAnimator.ofFloat(mImage, "translationX", 0, mXDelta), ObjectAnimator.ofFloat(mImage, "translationY", 0, mYDelta), ObjectAnimator.ofFloat(mImage, "scaleX", 1, mImageScale), ObjectAnimator.ofFloat(mImage, "scaleY", 1, mImageScale), // ObjectAnimator.ofFloat(mImage, "alpha", 1, 0), ObjectAnimator.ofFloat(mImage, "imageCrop", 0f, clipRatio), anim); set.setInterpolator(sAccelerator); set.setDuration(duration).start(); mPager.setVisibility(View.GONE); mIsAnimationPlaying = true; }
From source file:com.google.samples.apps.topeka.widget.quiz.AbsQuizView.java
private void resizeViewProperty(Property<View, Float> property, float targetScale, int durationOffset) { ObjectAnimator animator = ObjectAnimator.ofFloat(this, property, 1f, targetScale); animator.setInterpolator(mLinearOutSlowInInterpolator); animator.setStartDelay(FOREGROUND_COLOR_CHANGE_DELAY + durationOffset); animator.start();//w w w.j a va 2 s .co m }
From source file:com.android.tabletcustomui.views.LeftCircleContainer.java
private void animateClockWise(View view) { ObjectAnimator animation = ObjectAnimator.ofFloat(view, "rotation", 0.0f, 360f); animation.setDuration(3000);//from www.ja va 2s. c om animation.setInterpolator(new FastOutSlowInInterpolator()); animation.start(); }
From source file:com.android.tabletcustomui.views.LeftCircleContainer.java
private void animateAntiClockWise(View view) { ObjectAnimator animation1 = ObjectAnimator.ofFloat(view, "rotation", 360f, 0.0f); animation1.setDuration(3000);//from ww w.j a v a 2 s. c o m animation1.setInterpolator(new FastOutSlowInInterpolator()); animation1.start(); }
From source file:com.github.jokar.rxupload.widget.ProgressDownloadView.java
public void drawFail() { mState = State.STATE_FAILED;// w ww .ja v a 2 s . co m ObjectAnimator failAnim = ObjectAnimator.ofFloat(this, "failAngle", 0, 180); failAnim.setInterpolator(new OvershootInterpolator()); //This one doesn't do much actually, we just use it to take advantage of associating two different interpolators ObjectAnimator anim = ObjectAnimator.ofFloat(this, "progress", getProgress(), mTarget); anim.setInterpolator(new AccelerateInterpolator()); AnimatorSet set = new AnimatorSet(); set.setDuration((long) (ANIMATION_DURATION_BASE / 1.7f)); set.playTogether(failAnim, anim); set.start(); }