Search in sources :

Example 6 with BounceInterpolator

use of android.view.animation.BounceInterpolator in project Android-Developers-Samples by johnjohndoe.

the class DefaultCardStreamAnimator method getSwipeInAnimator.

@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@Override
public ObjectAnimator getSwipeInAnimator(View view, float deltaX, float deltaY) {
    float deltaXAbs = Math.abs(deltaX);
    float fractionCovered = 1.f - (deltaXAbs / view.getWidth());
    long duration = Math.abs((int) ((1 - fractionCovered) * 200 * mSpeedFactor));
    // Animate position and alpha of swiped item
    ObjectAnimator animator = ObjectAnimator.ofPropertyValuesHolder(view, PropertyValuesHolder.ofFloat("alpha", 1.f), PropertyValuesHolder.ofFloat("translationX", 0.f), PropertyValuesHolder.ofFloat("rotationY", 0.f));
    animator.setDuration(duration).setInterpolator(new BounceInterpolator());
    return animator;
}
Also used : ObjectAnimator(android.animation.ObjectAnimator) BounceInterpolator(android.view.animation.BounceInterpolator) TargetApi(android.annotation.TargetApi)

Example 7 with BounceInterpolator

use of android.view.animation.BounceInterpolator in project MaterialDesignLibrary by navasmdc.

the class ButtonFloat method show.

public void show() {
    ObjectAnimator animator = ObjectAnimator.ofFloat(ButtonFloat.this, "y", showPosition);
    animator.setInterpolator(new BounceInterpolator());
    animator.setDuration(1500);
    animator.start();
    isShow = true;
}
Also used : ObjectAnimator(com.nineoldandroids.animation.ObjectAnimator) BounceInterpolator(android.view.animation.BounceInterpolator)

Example 8 with BounceInterpolator

use of android.view.animation.BounceInterpolator in project WaveSwipeRefreshLayout by recruit-lifestyle.

the class WaveView method startWaveAnimation.

/**
   * @param h 波が始まる高さ
   */
public void startWaveAnimation(float h) {
    h = Math.min(h, MAX_WAVE_HEIGHT) * mWidth;
    mWaveReverseAnimator = ValueAnimator.ofFloat(h, 0.f);
    mWaveReverseAnimator.setDuration(WAVE_ANIMATOR_DURATION);
    mWaveReverseAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

        @Override
        public void onAnimationUpdate(ValueAnimator valueAnimator) {
            float h = (Float) valueAnimator.getAnimatedValue();
            mWavePath.moveTo(0, 0);
            mWavePath.quadTo(0.25f * mWidth, 0, 0.333f * mWidth, h * 0.5f);
            mWavePath.quadTo(mWidth * 0.5f, h * 1.4f, 0.666f * mWidth, h * 0.5f);
            mWavePath.quadTo(0.75f * mWidth, 0, mWidth, 0);
            postInvalidate();
        }
    });
    mWaveReverseAnimator.setInterpolator(new BounceInterpolator());
    mWaveReverseAnimator.start();
}
Also used : BounceInterpolator(android.view.animation.BounceInterpolator) ValueAnimator(android.animation.ValueAnimator)

Example 9 with BounceInterpolator

use of android.view.animation.BounceInterpolator in project Android-MaterialRefreshLayout by android-cjj.

the class MaterialWaveView method onRefreshing.

@Override
public void onRefreshing(MaterialRefreshLayout br) {
    setHeadHeight((int) (Util.dip2px(getContext(), DefaulHeadHeight)));
    ValueAnimator animator = ValueAnimator.ofInt(getWaveHeight(), 0);
    animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            Log.i("anim", "value--->" + (int) animation.getAnimatedValue());
            setWaveHeight((int) animation.getAnimatedValue());
            invalidate();
        }
    });
    animator.setInterpolator(new BounceInterpolator());
    animator.setDuration(200);
    animator.start();
}
Also used : BounceInterpolator(android.view.animation.BounceInterpolator) ValueAnimator(android.animation.ValueAnimator)

Example 10 with BounceInterpolator

use of android.view.animation.BounceInterpolator in project HTextView by hanks-zyh.

the class AnvilText method drawFrame.

@Override
protected void drawFrame(Canvas canvas) {
    float offset = startX;
    float oldOffset = oldStartX;
    int maxLength = Math.max(mText.length(), mOldText.length());
    float percent = progress;
    boolean showSmoke = false;
    for (int i = 0; i < maxLength; i++) {
        // draw old text
        if (i < mOldText.length()) {
            mOldPaint.setTextSize(mTextSize);
            int move = CharacterUtils.needMove(i, differentList);
            if (move != -1) {
                mOldPaint.setAlpha(255);
                float p = percent * 2f;
                p = p > 1 ? 1 : p;
                float distX = CharacterUtils.getOffset(i, move, p, startX, oldStartX, gaps, oldGaps);
                canvas.drawText(mOldText.charAt(i) + "", 0, 1, distX, startY, mOldPaint);
            } else {
                float p = percent * 2f;
                p = p > 1 ? 1 : p;
                mOldPaint.setAlpha((int) ((1 - p) * 255));
                canvas.drawText(mOldText.charAt(i) + "", 0, 1, oldOffset, startY, mOldPaint);
            }
            oldOffset += oldGaps[i];
        }
        // draw new text
        if (i < mText.length()) {
            if (!CharacterUtils.stayHere(i, differentList)) {
                showSmoke = true;
                float interpolation = new BounceInterpolator().getInterpolation(percent);
                mPaint.setAlpha(255);
                mPaint.setTextSize(mTextSize);
                float y = startY - (1 - interpolation) * mTextHeight * 2;
                float width = mPaint.measureText(mText.charAt(i) + "");
                canvas.drawText(mText.charAt(i) + "", 0, 1, offset + (gaps[i] - width) / 2, y, mPaint);
            }
            offset += gaps[i];
        }
    }
    if (percent > 0.3 && percent < 1) {
        if (showSmoke) {
            drawSmokes(canvas, startX + (offset - startX) / 2f, startY - 50, percent);
        }
    }
}
Also used : BounceInterpolator(android.view.animation.BounceInterpolator) Paint(android.graphics.Paint)

Aggregations

BounceInterpolator (android.view.animation.BounceInterpolator)30 View (android.view.View)8 AccelerateInterpolator (android.view.animation.AccelerateInterpolator)6 ImageView (android.widget.ImageView)6 ObjectAnimator (android.animation.ObjectAnimator)5 DecelerateInterpolator (android.view.animation.DecelerateInterpolator)5 LinearInterpolator (android.view.animation.LinearInterpolator)5 TextView (android.widget.TextView)5 AccelerateDecelerateInterpolator (android.view.animation.AccelerateDecelerateInterpolator)4 AnticipateInterpolator (android.view.animation.AnticipateInterpolator)4 AnticipateOvershootInterpolator (android.view.animation.AnticipateOvershootInterpolator)4 Interpolator (android.view.animation.Interpolator)4 OvershootInterpolator (android.view.animation.OvershootInterpolator)4 Scroller (android.widget.Scroller)4 Animator (android.animation.Animator)3 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)3 Animation (com.db.chart.animation.Animation)3 ValueAnimator (android.animation.ValueAnimator)2 SuppressLint (android.annotation.SuppressLint)2 DisplayMetrics (android.util.DisplayMetrics)2