Example usage for android.view View SCALE_X

List of usage examples for android.view View SCALE_X

Introduction

In this page you can find the example usage for android.view View SCALE_X.

Prototype

Property SCALE_X

To view the source code for android.view View SCALE_X.

Click Source Link

Document

A Property wrapper around the scaleX functionality handled by the View#setScaleX(float) and View#getScaleX() methods.

Usage

From source file:com.pitchedapps.primenumbercalculator.Calculator.java

License:asdf

private void onResult(final String result) {
    // Calculate the values needed to perform the scale and translation animations,
    // accounting for how the scale will affect the final position of the text.
    final float resultScale = mInputEditText.getVariableTextSize(result) / mResultEditText.getTextSize();
    final float resultTranslationX = (1.0f - resultScale)
            * (mResultEditText.getWidth() / 2.0f - mResultEditText.getPaddingEnd());
    final float resultTranslationY = (1.0f - resultScale) * //TODO delete unnecessary lines for animation
            (mResultEditText.getHeight() / 2.0f - mResultEditText.getPaddingBottom())
            + (mInputEditText.getBottom() - mResultEditText.getBottom())
            + (mResultEditText.getPaddingBottom() - mInputEditText.getPaddingBottom());
    final float inputTranslationY = -mInputEditText.getBottom();

    // Use a value animator to fade to the final text color over the course of the animation.
    final int resultTextColor = mResultEditText.getCurrentTextColor();
    final int inputEditText = mInputEditText.getCurrentTextColor();
    final ValueAnimator textColorAnimator = ValueAnimator.ofObject(new ArgbEvaluator(), resultTextColor,
            inputEditText);//from   w  w w.  jav  a2s.c o m
    textColorAnimator.addUpdateListener(new AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator valueAnimator) {
            mResultEditText.setTextColor((int) valueAnimator.getAnimatedValue());
        }
    });

    final AnimatorSet animatorSet = new AnimatorSet();
    animatorSet.playTogether(textColorAnimator,
            ObjectAnimator.ofFloat(mResultEditText, View.SCALE_X, resultScale),
            ObjectAnimator.ofFloat(mResultEditText, View.SCALE_Y, resultScale),
            ObjectAnimator.ofFloat(mResultEditText, View.TRANSLATION_X, resultTranslationX),
            ObjectAnimator.ofFloat(mResultEditText, View.TRANSLATION_Y, resultTranslationY),
            ObjectAnimator.ofFloat(mInputEditText, View.TRANSLATION_Y, inputTranslationY));
    animatorSet.setDuration(getResources().getInteger(android.R.integer.config_longAnimTime));
    animatorSet.setInterpolator(new AccelerateDecelerateInterpolator());
    animatorSet.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationStart(Animator animation) {
            mResultEditText.setText(result);
        }

        @Override
        public void onAnimationEnd(Animator animation) {
            // Reset all of the values modified during the animation.
            mResultEditText.setTextColor(resultTextColor);
            mResultEditText.setScaleX(1.0f);
            mResultEditText.setScaleY(1.0f);
            mResultEditText.setTranslationX(0.0f);
            mResultEditText.setTranslationY(0.0f);
            mInputEditText.setTranslationY(0.0f);

            // Finally update the input to use the current result.
            mInputEditText.setText(result); //TODO figure out how to reset after equal sign without changing input text
            mResultEditText.getEditableText().clear();
            setState(CalculatorState.RESULT);

            mCurrentAnimator = null;
        }

    });

    mCurrentAnimator = animatorSet;
    animatorSet.start();
}

From source file:org.mariotaku.twidere.fragment.support.AccountsDashboardFragment.java

private void onAccountSelected(AccountProfileImageViewHolder holder, final ParcelableAccount account) {
    if (mSwitchAccountAnimationPlaying)
        return;/*  w w w  .  j a  v  a  2s  .  co  m*/
    final ImageView snapshotView = mFloatingProfileImageSnapshotView;
    final ShapedImageView profileImageView = mAccountProfileImageView;
    final ShapedImageView clickedImageView = holder.getIconView();

    // Reset snapshot view position
    snapshotView.setPivotX(0);
    snapshotView.setPivotY(0);
    snapshotView.setTranslationX(0);
    snapshotView.setTranslationY(0);

    final Matrix matrix = new Matrix();
    final RectF sourceBounds = new RectF(), destBounds = new RectF(), snapshotBounds = new RectF();
    getLocationOnScreen(clickedImageView, sourceBounds);
    getLocationOnScreen(profileImageView, destBounds);
    getLocationOnScreen(snapshotView, snapshotBounds);
    final float finalScale = destBounds.width() / sourceBounds.width();
    final Bitmap snapshotBitmap = TransitionUtils.createViewBitmap(clickedImageView, matrix,
            new RectF(0, 0, sourceBounds.width(), sourceBounds.height()));
    final ViewGroup.LayoutParams lp = snapshotView.getLayoutParams();
    lp.width = clickedImageView.getWidth();
    lp.height = clickedImageView.getHeight();
    snapshotView.setLayoutParams(lp);
    // Copied from MaterialNavigationDrawer: https://github.com/madcyph3r/AdvancedMaterialDrawer/
    AnimatorSet set = new AnimatorSet();
    set.play(ObjectAnimator.ofFloat(snapshotView, View.TRANSLATION_X, sourceBounds.left - snapshotBounds.left,
            destBounds.left - snapshotBounds.left))
            .with(ObjectAnimator.ofFloat(snapshotView, View.TRANSLATION_Y,
                    sourceBounds.top - snapshotBounds.top, destBounds.top - snapshotBounds.top))
            .with(ObjectAnimator.ofFloat(snapshotView, View.SCALE_X, 1, finalScale))
            .with(ObjectAnimator.ofFloat(snapshotView, View.SCALE_Y, 1, finalScale))
            .with(ObjectAnimator.ofFloat(profileImageView, View.ALPHA, 1, 0))
            .with(ObjectAnimator.ofFloat(clickedImageView, View.SCALE_X, 0, 1))
            .with(ObjectAnimator.ofFloat(clickedImageView, View.SCALE_Y, 0, 1));
    final long animationTransition = 400;
    set.setDuration(animationTransition);
    set.setInterpolator(new DecelerateInterpolator());
    set.addListener(new AnimatorListener() {

        private Drawable clickedDrawable;
        private int[] clickedColors;

        @Override
        public void onAnimationStart(Animator animation) {
            snapshotView.setVisibility(View.VISIBLE);
            snapshotView.setImageBitmap(snapshotBitmap);
            final Drawable profileDrawable = profileImageView.getDrawable();
            clickedDrawable = clickedImageView.getDrawable();
            clickedColors = clickedImageView.getBorderColors();
            final ParcelableAccount oldSelectedAccount = mAccountsAdapter.getSelectedAccount();
            mImageLoader.displayDashboardProfileImage(clickedImageView, oldSelectedAccount.profile_image_url,
                    profileDrawable);
            //                mImageLoader.displayDashboardProfileImage(profileImageView,
            //                        account.profile_image_url, clickedDrawable);
            clickedImageView.setBorderColors(profileImageView.getBorderColors());
            mSwitchAccountAnimationPlaying = true;
        }

        @Override
        public void onAnimationEnd(Animator animation) {
            finishAnimation();
        }

        @Override
        public void onAnimationCancel(Animator animation) {
            finishAnimation();
        }

        @Override
        public void onAnimationRepeat(Animator animation) {

        }

        private void finishAnimation() {
            final Editor editor = mPreferences.edit();
            editor.putLong(KEY_DEFAULT_ACCOUNT_ID, account.account_id);
            editor.apply();
            mAccountsAdapter.setSelectedAccountId(account.account_id);
            mAccountOptionsAdapter.setSelectedAccount(account);
            updateAccountOptionsSeparatorLabel(clickedDrawable);
            snapshotView.setVisibility(View.INVISIBLE);
            snapshotView.setImageDrawable(null);
            profileImageView.setImageDrawable(clickedDrawable);
            profileImageView.setBorderColors(clickedColors);
            profileImageView.setAlpha(1f);
            clickedImageView.setScaleX(1);
            clickedImageView.setScaleY(1);
            clickedImageView.setAlpha(1f);
            mSwitchAccountAnimationPlaying = false;
        }
    });
    set.start();
}

From source file:com.android.deskclock.timer.TimerFullScreenFragment.java

private void gotoSetupView() {
    if (mLastVisibleView == null || mLastVisibleView.getId() == R.id.timer_setup) {
        mTimerSetup.setVisibility(View.VISIBLE);
        mTimerSetup.setScaleX(1f);// w ww  . ja v  a 2 s  . c  o  m
        mTimersListPage.setVisibility(View.GONE);
    } else {
        // Animate
        ObjectAnimator a = ObjectAnimator.ofFloat(mTimersListPage, View.SCALE_X, 1f, 0f);
        a.setInterpolator(new AccelerateInterpolator());
        a.setDuration(125);
        a.addListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationEnd(Animator animation) {
                mTimersListPage.setVisibility(View.GONE);
                mTimerSetup.setScaleX(0);
                mTimerSetup.setVisibility(View.VISIBLE);
                ObjectAnimator b = ObjectAnimator.ofFloat(mTimerSetup, View.SCALE_X, 0f, 1f);
                b.setInterpolator(new DecelerateInterpolator());
                b.setDuration(225);
                b.start();
            }
        });
        a.start();

    }
    stopClockTicks();
    mTimerSetup.updateDeleteButtonAndDivider();
    mLastVisibleView = mTimerSetup;
}

From source file:org.mariotaku.twidere.fragment.AccountsDashboardFragment.java

private void onAccountSelected(AccountProfileImageViewHolder holder, @NonNull final ParcelableAccount account) {
    if (mSwitchAccountAnimationPlaying)
        return;//from w  w w .j  av  a2  s  .  co m
    final ImageView snapshotView = mFloatingProfileImageSnapshotView;
    final ShapedImageView profileImageView = mAccountProfileImageView;
    final ShapedImageView clickedImageView = holder.getIconView();

    // Reset snapshot view position
    snapshotView.setPivotX(0);
    snapshotView.setPivotY(0);
    snapshotView.setTranslationX(0);
    snapshotView.setTranslationY(0);

    final Matrix matrix = new Matrix();
    final RectF sourceBounds = new RectF(), destBounds = new RectF(), snapshotBounds = new RectF();
    getLocationOnScreen(clickedImageView, sourceBounds);
    getLocationOnScreen(profileImageView, destBounds);
    getLocationOnScreen(snapshotView, snapshotBounds);
    final float finalScale = destBounds.width() / sourceBounds.width();
    final Bitmap snapshotBitmap = TransitionUtils.createViewBitmap(clickedImageView, matrix,
            new RectF(0, 0, sourceBounds.width(), sourceBounds.height()));
    final ViewGroup.LayoutParams lp = snapshotView.getLayoutParams();
    lp.width = clickedImageView.getWidth();
    lp.height = clickedImageView.getHeight();
    snapshotView.setLayoutParams(lp);
    // Copied from MaterialNavigationDrawer: https://github.com/madcyph3r/AdvancedMaterialDrawer/
    AnimatorSet set = new AnimatorSet();
    set.play(ObjectAnimator.ofFloat(snapshotView, View.TRANSLATION_X, sourceBounds.left - snapshotBounds.left,
            destBounds.left - snapshotBounds.left))
            .with(ObjectAnimator.ofFloat(snapshotView, View.TRANSLATION_Y,
                    sourceBounds.top - snapshotBounds.top, destBounds.top - snapshotBounds.top))
            .with(ObjectAnimator.ofFloat(snapshotView, View.SCALE_X, 1, finalScale))
            .with(ObjectAnimator.ofFloat(snapshotView, View.SCALE_Y, 1, finalScale))
            .with(ObjectAnimator.ofFloat(profileImageView, View.ALPHA, 1, 0))
            .with(ObjectAnimator.ofFloat(clickedImageView, View.SCALE_X, 0, 1))
            .with(ObjectAnimator.ofFloat(clickedImageView, View.SCALE_Y, 0, 1));
    final long animationTransition = 400;
    set.setDuration(animationTransition);
    set.setInterpolator(new DecelerateInterpolator());
    set.addListener(new AnimatorListener() {

        private Drawable clickedDrawable;
        private int[] clickedColors;

        @Override
        public void onAnimationStart(Animator animation) {
            snapshotView.setVisibility(View.VISIBLE);
            snapshotView.setImageBitmap(snapshotBitmap);
            final Drawable profileDrawable = profileImageView.getDrawable();
            clickedDrawable = clickedImageView.getDrawable();
            clickedColors = clickedImageView.getBorderColors();
            final ParcelableAccount oldSelectedAccount = mAccountsAdapter.getSelectedAccount();
            if (oldSelectedAccount == null)
                return;
            mMediaLoader.displayDashboardProfileImage(clickedImageView, oldSelectedAccount, profileDrawable);
            clickedImageView.setBorderColors(profileImageView.getBorderColors());

            displayAccountBanner(account);

            mSwitchAccountAnimationPlaying = true;
        }

        @Override
        public void onAnimationEnd(Animator animation) {
            finishAnimation();
        }

        @Override
        public void onAnimationCancel(Animator animation) {
            finishAnimation();
        }

        @Override
        public void onAnimationRepeat(Animator animation) {

        }

        private void finishAnimation() {
            final Editor editor = mPreferences.edit();
            editor.putString(KEY_DEFAULT_ACCOUNT_KEY, account.account_key.toString());
            editor.apply();
            mAccountsAdapter.setSelectedAccount(account);
            updateAccountActions();
            displayCurrentAccount(clickedDrawable);
            snapshotView.setVisibility(View.INVISIBLE);
            snapshotView.setImageDrawable(null);
            profileImageView.setImageDrawable(clickedDrawable);
            profileImageView.setBorderColors(clickedColors);
            profileImageView.setAlpha(1f);
            clickedImageView.setScaleX(1);
            clickedImageView.setScaleY(1);
            clickedImageView.setAlpha(1f);
            mSwitchAccountAnimationPlaying = false;
        }
    });
    set.start();

}

From source file:com.waz.zclient.pages.main.conversation.SingleImageFragment.java

private AnimatorSet getSaveImageAnimation(final ImageAsset image) {
    int totalAnimationDuration = getResources().getInteger(R.integer.framework_animation_duration_long);

    ObjectAnimator fadeOutAnimator = ObjectAnimator.ofFloat(saveImageViewContainer, View.ALPHA, 1, 0);
    fadeOutAnimator.setDuration(totalAnimationDuration);

    ObjectAnimator scaleDownXAnimator = ObjectAnimator.ofFloat(saveImageViewContainer, View.SCALE_X, 0f);
    ObjectAnimator scaleDownYAnimator = ObjectAnimator.ofFloat(saveImageViewContainer, View.SCALE_Y, 0f);
    scaleDownXAnimator.setDuration(totalAnimationDuration);
    scaleDownYAnimator.setDuration(totalAnimationDuration);

    int moveY = ViewUtils.getOrientationIndependentDisplayHeight(getActivity()) / 2;
    int moveX;/*  ww w  .ja va  2 s.  com*/
    if (ViewUtils.isInLandscape(getActivity())) {
        moveX = ViewUtils.getOrientationIndependentDisplayWidth(getActivity());
    } else {
        moveX = ViewUtils.getOrientationIndependentDisplayWidth(getActivity()) / 2;
    }
    ObjectAnimator moveXAnimator = ObjectAnimator.ofFloat(saveImageViewContainer, View.TRANSLATION_X, -moveX);
    ObjectAnimator moveYAnimator = ObjectAnimator.ofFloat(saveImageViewContainer, View.TRANSLATION_Y, moveY);
    moveXAnimator.setDuration(totalAnimationDuration);
    moveYAnimator.setDuration(totalAnimationDuration);

    // Fade out top image view for blur effect
    ObjectAnimator fadeToBlurredAnimator = ObjectAnimator.ofFloat(saveImageView, View.ALPHA, 1, 0);
    fadeToBlurredAnimator.setDuration(getResources().getInteger(R.integer.framework_animation_duration_medium));

    AnimatorSet animatorSet = new AnimatorSet();
    animatorSet.setInterpolator(new Expo.EaseIn());
    animatorSet.playTogether(fadeOutAnimator, scaleDownXAnimator, scaleDownYAnimator, moveXAnimator,
            moveYAnimator, fadeToBlurredAnimator);

    animatorSet.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            if (getStoreFactory() == null || getStoreFactory().isTornDown()) {
                return;
            }

            resetSaveImageView();

            // Image saving is called here, as an image save triggers a notification which contains a bitmap;
            // currently that bitmap is quite large, android.app.Notification writes the bitmap to a parcel
            // on the main thread, dropping a large number of frames and breaking the save animation
            image.saveImageToGallery(SingleImageFragment.this);

            enableSaveImageButton(true);
        }
    });

    return animatorSet;
}

From source file:com.tiancaicc.springfloatingactionmenu.SpringFloatingActionMenu.java

private void applyTumblrOpenAniamtion() {
    final View firstItem = mMenuItemViews.get(0);

    //make start position at center
    for (MenuItemView itemView : mMenuItemViews) {
        itemView.disableAlphaAnimation();
        itemView.setX(firstItem.getLeft());
        itemView.setY(firstItem.getY());
        itemView.setScaleX(0);/*w  ww  .j av  a  2s .  com*/
        itemView.setScaleY(0);
    }
    final SpringSystem springSystem = SpringSystem.create();

    final Spring springScaleX = springSystem.createSpring();
    final Spring springScaleY = springSystem.createSpring();

    springScaleX.addListener(new MapPerformer(firstItem, View.SCALE_X, 0, 1));
    springScaleY.addListener(new MapPerformer(firstItem, View.SCALE_Y, 0, 1));
    final DestroySelfSpringListener destroySelfSpringListener = new DestroySelfSpringListener(this,
            mContainerView, true);
    springScaleX.addListener(destroySelfSpringListener);
    springScaleY.addListener(destroySelfSpringListener);
    springScaleX.setEndValue(1);
    springScaleY.setEndValue(1);

    for (int i = 1; i < mMenuItemCount; i++) {
        final View menuItemView = mMenuItemViews.get(i);
        new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {

                final Spring springScaleX = springSystem.createSpring();
                final Spring springScaleY = springSystem.createSpring();

                springScaleX.addListener(new MapPerformer(menuItemView, View.SCALE_X, 0, 1));
                springScaleY.addListener(new MapPerformer(menuItemView, View.SCALE_Y, 0, 1));
                final DestroySelfSpringListener destroySelfSpringListener = new DestroySelfSpringListener(
                        SpringFloatingActionMenu.this, mContainerView, true);
                springScaleX.addListener(destroySelfSpringListener);
                springScaleY.addListener(destroySelfSpringListener);
                springScaleX.setEndValue(1);
                springScaleY.setEndValue(1);

                final Spring springX = springSystem.createSpring();
                final Spring springY = springSystem.createSpring();

                springX.addListener(
                        new MapPerformer(menuItemView, View.X, firstItem.getLeft(), menuItemView.getLeft()));
                springY.addListener(
                        new MapPerformer(menuItemView, View.Y, firstItem.getTop(), menuItemView.getTop()));
                springX.addListener(destroySelfSpringListener);
                springY.addListener(destroySelfSpringListener);
                springX.setEndValue(1);
                springY.setEndValue(1);
            }
        }, mTumblrTimeInterval * (i - 1));
    }
}

From source file:com.android.deskclock.timer.TimerFullScreenFragment.java

private void gotoTimersView() {
    if (mLastVisibleView == null || mLastVisibleView.getId() == R.id.timers_list_page) {
        mTimerSetup.setVisibility(View.GONE);
        mTimersListPage.setVisibility(View.VISIBLE);
        mTimersListPage.setScaleX(1f);//from  w  ww .  j  a va2  s.com
    } else {
        // Animate
        ObjectAnimator a = ObjectAnimator.ofFloat(mTimerSetup, View.SCALE_X, 1f, 0f);
        a.setInterpolator(new AccelerateInterpolator());
        a.setDuration(125);
        a.addListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationEnd(Animator animation) {
                mTimerSetup.setVisibility(View.GONE);
                mTimersListPage.setScaleX(0);
                mTimersListPage.setVisibility(View.VISIBLE);
                ObjectAnimator b = ObjectAnimator.ofFloat(mTimersListPage, View.SCALE_X, 0f, 1f);
                b.setInterpolator(new DecelerateInterpolator());
                b.setDuration(225);
                b.start();
            }
        });
        a.start();
    }
    startClockTicks();
    mLastVisibleView = mTimersListPage;
}

From source file:com.tiancaicc.springfloatingactionmenu.SpringFloatingActionMenu.java

private void applyTumblrCloseAnimation() {

    final int alphaDuration = 130;

    final SpringSystem springSystem = SpringSystem.create();

    final View firstItem = mMenuItemViews.get(0);
    final Spring springScaleX = springSystem.createSpring();
    final Spring springScaleY = springSystem.createSpring();

    springScaleX.addListener(new MapPerformer(firstItem, View.SCALE_X, 1, 0));
    springScaleY.addListener(new MapPerformer(firstItem, View.SCALE_Y, 1, 0));
    final DestroySelfSpringListener destroySelfSpringListener = new DestroySelfSpringListener(this,
            mContainerView, false);//from  w w w .  j  a v  a2s . c o  m
    springScaleX.addListener(destroySelfSpringListener);
    springScaleY.addListener(destroySelfSpringListener);
    springScaleX.setEndValue(1);
    springScaleY.setEndValue(1);

    firstItem.animate().alpha(160);

    for (int i = mMenuItemCount - 1; i >= 1; i--) {
        final View menuItemView = mMenuItemViews.get(i);
        new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {

                final Spring springScaleX = springSystem.createSpring();
                final Spring springScaleY = springSystem.createSpring();

                springScaleX.addListener(new MapPerformer(menuItemView, View.SCALE_X, 1, 0));
                springScaleY.addListener(new MapPerformer(menuItemView, View.SCALE_Y, 1, 0));
                final DestroySelfSpringListener destroySelfSpringListener = new DestroySelfSpringListener(
                        SpringFloatingActionMenu.this, mContainerView, false);
                springScaleX.addListener(destroySelfSpringListener);
                springScaleY.addListener(destroySelfSpringListener);
                springScaleX.setEndValue(1);
                springScaleY.setEndValue(1);

                final Spring springX = springSystem.createSpring();
                final Spring springY = springSystem.createSpring();

                springX.addListener(
                        new MapPerformer(menuItemView, View.X, menuItemView.getLeft(), firstItem.getLeft()));
                springY.addListener(
                        new MapPerformer(menuItemView, View.Y, menuItemView.getTop(), firstItem.getTop()));
                springX.addListener(destroySelfSpringListener);
                springY.addListener(destroySelfSpringListener);
                springX.setEndValue(1);
                springY.setEndValue(1);

                menuItemView.animate().alpha(0).setDuration(alphaDuration);
            }
        }, mTumblrTimeInterval * (mMenuItemCount - i - 1));
    }
}

From source file:io.plaidapp.ui.DribbbleShot.java

/**
 * Animate in the title, description and author  can't do this in a content transition as they
 * are within the ListView so do it manually.  Also handle the FAB tanslation here so that it
 * plays nicely with #calculateFabPosition
 *///from   w  ww .  j ava  2s.c  o m
private void enterAnimation(boolean isOrientationChange) {
    Interpolator interp = AnimationUtils.loadInterpolator(this, android.R.interpolator.fast_out_slow_in);
    int offset = title.getHeight();
    viewEnterAnimation(title, offset, interp);
    if (description.getVisibility() == View.VISIBLE) {
        offset *= 1.5f;
        viewEnterAnimation(description, offset, interp);
    }
    // animate the fab without touching the alpha as this is handled in the content transition
    offset *= 1.5f;
    float fabTransY = fab.getTranslationY();
    fab.setTranslationY(fabTransY + offset);
    fab.animate().translationY(fabTransY).setDuration(600).setInterpolator(interp).start();
    offset *= 1.5f;
    viewEnterAnimation(shotActions, offset, interp);
    offset *= 1.5f;
    viewEnterAnimation(playerName, offset, interp);
    viewEnterAnimation(playerAvatar, offset, interp);
    viewEnterAnimation(shotTimeAgo, offset, interp);
    back.animate().alpha(1f).setDuration(600).setInterpolator(interp).start();

    if (isOrientationChange) {
        // we rely on the window enter content transition to show the fab. This isn't run on
        // orientation changes so manually show it.
        Animator showFab = ObjectAnimator.ofPropertyValuesHolder(fab,
                PropertyValuesHolder.ofFloat(View.ALPHA, 0f, 1f),
                PropertyValuesHolder.ofFloat(View.SCALE_X, 0f, 1f),
                PropertyValuesHolder.ofFloat(View.SCALE_Y, 0f, 1f));
        showFab.setStartDelay(300L);
        showFab.setDuration(300L);
        showFab.setInterpolator(
                AnimationUtils.loadInterpolator(this, android.R.interpolator.linear_out_slow_in));
        showFab.start();
    }
}

From source file:com.android.calculator2.Calculator.java

private void onResult(boolean animate) {
    // Calculate the textSize that would be used to display the result in the formula.
    // For scrollable results just use the minimum textSize to maximize the number of digits
    // that are visible on screen.
    float textSize = mFormulaText.getMinimumTextSize();
    if (!mResultText.isScrollable()) {
        textSize = mFormulaText.getVariableTextSize(mResultText.getText().toString());
    }/*  www. java  2s. c om*/

    // Scale the result to match the calculated textSize, minimizing the jump-cut transition
    // when a result is reused in a subsequent expression.
    final float resultScale = textSize / mResultText.getTextSize();

    // Set the result's pivot to match its gravity.
    mResultText.setPivotX(mResultText.getWidth() - mResultText.getPaddingRight());
    mResultText.setPivotY(mResultText.getHeight() - mResultText.getPaddingBottom());

    // Calculate the necessary translations so the result takes the place of the formula and
    // the formula moves off the top of the screen.
    final float resultTranslationY = (mFormulaText.getBottom() - mResultText.getBottom())
            - (mFormulaText.getPaddingBottom() - mResultText.getPaddingBottom());
    final float formulaTranslationY = -mFormulaText.getBottom();

    // Change the result's textColor to match the formula.
    final int formulaTextColor = mFormulaText.getCurrentTextColor();

    if (animate) {
        mResultText.announceForAccessibility(getResources().getString(R.string.desc_eq));
        mResultText.announceForAccessibility(mResultText.getText());
        setState(CalculatorState.ANIMATE);
        final AnimatorSet animatorSet = new AnimatorSet();
        animatorSet.playTogether(
                ObjectAnimator.ofPropertyValuesHolder(mResultText,
                        PropertyValuesHolder.ofFloat(View.SCALE_X, resultScale),
                        PropertyValuesHolder.ofFloat(View.SCALE_Y, resultScale),
                        PropertyValuesHolder.ofFloat(View.TRANSLATION_Y, resultTranslationY)),
                ObjectAnimator.ofArgb(mResultText, TEXT_COLOR, formulaTextColor),
                ObjectAnimator.ofFloat(mFormulaText, View.TRANSLATION_Y, formulaTranslationY));
        animatorSet.setDuration(getResources().getInteger(android.R.integer.config_longAnimTime));
        animatorSet.addListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationEnd(Animator animation) {
                setState(CalculatorState.RESULT);
                mCurrentAnimator = null;
            }
        });

        mCurrentAnimator = animatorSet;
        animatorSet.start();
    } else /* No animation desired; get there fast, e.g. when restarting */ {
        mResultText.setScaleX(resultScale);
        mResultText.setScaleY(resultScale);
        mResultText.setTranslationY(resultTranslationY);
        mResultText.setTextColor(formulaTextColor);
        mFormulaText.setTranslationY(formulaTranslationY);
        setState(CalculatorState.RESULT);
    }
}