當前位置: 首頁>>代碼示例>>Java>>正文


Java ValueAnimator.ofFloat方法代碼示例

本文整理匯總了Java中android.animation.ValueAnimator.ofFloat方法的典型用法代碼示例。如果您正苦於以下問題:Java ValueAnimator.ofFloat方法的具體用法?Java ValueAnimator.ofFloat怎麽用?Java ValueAnimator.ofFloat使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.animation.ValueAnimator的用法示例。


在下文中一共展示了ValueAnimator.ofFloat方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: expand

import android.animation.ValueAnimator; //導入方法依賴的package包/類
private void expand() {
    mExpanded = true;
    if (mArrow != null) {
        mArrow.animate().rotationX(0).setDuration(500).start();
        if (mAnimator != null) {
            mAnimator.cancel();
        }
        if (mItems == null) return;
        mAnimator = ValueAnimator.ofFloat(0, mItemHeight * mItems.size());
        mAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
            @Override
            public void onAnimationUpdate(ValueAnimator animation) {
                setHeight(Math.round((float) animation.getAnimatedValue()));
            }
        });
        mAnimator.setDuration(500);
        mAnimator.start();
    }
}
 
開發者ID:morogoku,項目名稱:MTweaks-KernelAdiutorMOD,代碼行數:20,代碼來源:DropDownView.java

示例2: endAnimation

import android.animation.ValueAnimator; //導入方法依賴的package包/類
@Override
public void endAnimation(DynamicWeatherView dynamicWeatherView, Animator.AnimatorListener listener) {
    super.endAnimation(dynamicWeatherView, listener);

    ValueAnimator animator1 = ValueAnimator.ofFloat(1, 0);
    animator1.setInterpolator(new AccelerateInterpolator());
    animator1.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            speed = (float) animation.getAnimatedValue() * 32;
            rotate = (float) animation.getAnimatedValue();
        }
    });

    AnimatorSet animSet = new AnimatorSet();
    animSet.play(animator1);
    animSet.setDuration(1000);
    if (listener != null) {
        animSet.addListener(listener);
    }
    animSet.start();
}
 
開發者ID:li-yu,項目名稱:FakeWeather,代碼行數:23,代碼來源:SandstormType.java

示例3: createAnimation

import android.animation.ValueAnimator; //導入方法依賴的package包/類
@Override
public List<Animator> createAnimation() {
    List<Animator> animators=new ArrayList<>();
    long[] delays=new long[]{500,250,0,250,500};
    for (int i = 0; i < 5; i++) {
        final int index=i;
        ValueAnimator scaleAnim=ValueAnimator.ofFloat(1,0.3f,1);
        scaleAnim.setDuration(900);
        scaleAnim.setRepeatCount(-1);
        scaleAnim.setStartDelay(delays[i]);
        scaleAnim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
            @Override
            public void onAnimationUpdate(ValueAnimator animation) {
                scaleYFloats[index] = (float) animation.getAnimatedValue();
                postInvalidate();
            }
        });
        scaleAnim.start();
        animators.add(scaleAnim);
    }
    return animators;
}
 
開發者ID:magicbaby810,項目名稱:SRecyclerView,代碼行數:23,代碼來源:LineScalePulseOutIndicator.java

示例4: createBallJumpAnimators

import android.animation.ValueAnimator; //導入方法依賴的package包/類
public ArrayList<ValueAnimator> createBallJumpAnimators() {
    ArrayList<ValueAnimator> animators = new ArrayList<>();
    int[] delays = new int[]{70, 140, 210};
    for (int i = 0; i < 3; i++) {
        final int index = i;
        ValueAnimator scaleAnim = ValueAnimator.ofFloat(mTextBottomBorder, mTextBottomBorder - mBallRadius * 2, mTextBottomBorder);
        scaleAnim.setDuration(600);
        scaleAnim.setRepeatCount(-1);
        scaleAnim.setStartDelay(delays[i]);
        scaleAnim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
            @Override
            public void onAnimationUpdate(ValueAnimator animation) {
                translateYFloats[index] = (float) animation.getAnimatedValue();
                postInvalidate();
            }
        });
        animators.add(scaleAnim);
    }
    return animators;
}
 
開發者ID:hiwhitley,項目名稱:DownloadProgressButton,代碼行數:21,代碼來源:DownloadProgressButton.java

示例5: onLayoutChange

import android.animation.ValueAnimator; //導入方法依賴的package包/類
@Override
public void onLayoutChange(View v, int left, int top, int right, int bottom,
        int oldLeft, int oldTop, int oldRight, int oldBottom) {
    if (mSheetAnimator != null) mSheetAnimator.cancel();

    mRequestView.removeOnLayoutChangeListener(this);
    mContainerHeightDifference = (bottom - top) - (oldBottom - oldTop);

    ValueAnimator containerAnimator = ValueAnimator.ofFloat(1f, 0f);
    containerAnimator.addUpdateListener(new AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            float alpha = (Float) animation.getAnimatedValue();
            update(alpha);
        }
    });

    mSheetAnimator = containerAnimator;
    mSheetAnimator.setDuration(DIALOG_ENTER_ANIMATION_MS);
    mSheetAnimator.setInterpolator(new LinearOutSlowInInterpolator());
    mSheetAnimator.addListener(this);
    mSheetAnimator.start();
}
 
開發者ID:rkshuai,項目名稱:chromium-for-android-56-debug-video,代碼行數:24,代碼來源:PaymentRequestUI.java

示例6: startAnimation

import android.animation.ValueAnimator; //導入方法依賴的package包/類
/**
 * アニメーションを開始する
 */
public void startAnimation() {
    mCenterEdgeAnimator = ValueAnimator.ofFloat(1.f, 0.5f);
    mCenterEdgeAnimator.setDuration(100 * SPEED);
    mCenterEdgeAnimator.addUpdateListener(mAnimatorUpdateListener);

    mLeftEdgeAnimator = ValueAnimator.ofFloat((float) (-0.2 * SQRT_3), 0.f);
    mLeftEdgeAnimator.setDuration(100 * SPEED);
    mLeftEdgeAnimator.addUpdateListener(mAnimatorUpdateListener);

    mRightEdgeAnimator = ValueAnimator.ofFloat(1.f, 0.f);
    mRightEdgeAnimator.setDuration(150 * SPEED);
    mRightEdgeAnimator.addUpdateListener(mAnimatorUpdateListener);

    if (!mPlayed) {
        mCenterEdgeAnimator.start();
        mLeftEdgeAnimator.start();
        mRightEdgeAnimator.start();
    } else {
        mCenterEdgeAnimator.reverse();
        mLeftEdgeAnimator.reverse();
        mRightEdgeAnimator.reverse();
    }
}
 
開發者ID:popo1379,項目名稱:popomusic,代碼行數:27,代碼來源:PlayPauseButton.java

示例7: createAnimation

import android.animation.ValueAnimator; //導入方法依賴的package包/類
@Override
public List<Animator> createAnimation() {
    List<Animator> animators=new ArrayList<>();
    float circleSpacing=4;
    float radius=(getWidth()-circleSpacing*2)/6;
    int[] delays=new int[]{70,140,210};
    for (int i = 0; i < 3; i++) {
        final int index=i;
        ValueAnimator scaleAnim=ValueAnimator.ofFloat(getHeight()/2,getHeight()/2-radius*2,getHeight()/2);
        scaleAnim.setDuration(600);
        scaleAnim.setRepeatCount(-1);
        scaleAnim.setStartDelay(delays[i]);
        scaleAnim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
            @Override
            public void onAnimationUpdate(ValueAnimator animation) {
                translateYFloats[index] = (float) animation.getAnimatedValue();
                postInvalidate();
            }
        });
        scaleAnim.start();
        animators.add(scaleAnim);
    }
    return animators;
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:25,代碼來源:BallPulseSyncIndicator.java

示例8: startAnim

import android.animation.ValueAnimator; //導入方法依賴的package包/類
@Override
public void startAnim() {
    mAnimator = ValueAnimator.ofFloat(0, 1);
    mAnimator.setDuration(mDuration);
    mAnimator.setRepeatCount(0);
    mAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            float factor = (float) animation.getAnimatedValue();
            mSweepArg = (int) (90 * factor);
            mSecPoint.y = (int) (mFirPoint.y + 2 * MAX_RADIUS_CIRCLE * factor);

        }
    });
    mAnimator.start();
}
 
開發者ID:chengkun123,項目名稱:ReadMark,代碼行數:17,代碼來源:RLetterS.java

示例9: init

import android.animation.ValueAnimator; //導入方法依賴的package包/類
private void init() {

        // init animator
        mValueAnimator = ValueAnimator.ofFloat(0, mProgressValue);
        mValueAnimator.setDuration(DEFAULT_ANIMATION_TIME);
        mValueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
            @Override
            public void onAnimationUpdate(ValueAnimator valueAnimator) {
                mProgressValue = (float) valueAnimator.getAnimatedValue();
                invalidate();
            }
        });

        super.setScaleType(SCALE_TYPE);
        mReady = true;

        if (mSetupPending) {
            setup();
            mSetupPending = false;
        }
    }
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:22,代碼來源:CircularMusicProgressBar.java

示例10: doExitAnim

import android.animation.ValueAnimator; //導入方法依賴的package包/類
public void doExitAnim(final View contentView, long animDuration) {
    if (builder.gravity == Gravity.BOTTOM) {
        ValueAnimator exitAnimator = ValueAnimator.ofFloat(0, contentView.getHeight());
        exitAnimator.setDuration(animDuration);
        exitAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
            @Override
            public void onAnimationUpdate(ValueAnimator animation) {
                float value = (float) animation.getAnimatedValue();
                contentView.setTranslationY(value);
            }
        });
        exitAnimator.start();
    } else {
        ScaleAnimation scaleAnimation = new ScaleAnimation(1.0F, 0.0F, 1.0F, 0.0F,
                Animation.RELATIVE_TO_PARENT, 0.5F, Animation.RELATIVE_TO_PARENT, 0.5F);
        scaleAnimation.setDuration(animDuration);
        scaleAnimation.setFillAfter(true);
        contentView.startAnimation(scaleAnimation);
    }
}
 
開發者ID:devilist,項目名稱:RecyclerWheelPicker,代碼行數:21,代碼來源:WheelPicker.java

示例11: getResetYAnimator

import android.animation.ValueAnimator; //導入方法依賴的package包/類
/**
 * 垂直方向的重置動畫
 *
 * @return
 */
private ValueAnimator getResetYAnimator() {
    if (resetYAnimator != null) {
        resetYAnimator.removeAllUpdateListeners();
    } else {
        resetYAnimator = ValueAnimator.ofFloat();
    }
    resetYAnimator.setDuration(150);
    resetYAnimator.setInterpolator(mAccInterpolator);
    resetYAnimator.setEvaluator(mFloatEvaluator);
    return resetYAnimator;
}
 
開發者ID:hsj-xiaokang,項目名稱:OSchina_resources_android,代碼行數:17,代碼來源:ImagePreviewView.java

示例12: getTranslateXAnimation

import android.animation.ValueAnimator; //導入方法依賴的package包/類
private ValueAnimator getTranslateXAnimation() {
    final ValueAnimator animator = ValueAnimator.ofFloat(mTranslateX, 0);
    animator.setDuration(animationDuration);
    animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator valueAnimator) {
            mTranslateX = (float) valueAnimator.getAnimatedValue();
        }
    });

    return animator;
}
 
開發者ID:miaoyongjun,項目名稱:MVideo,代碼行數:13,代碼來源:DragVideoView.java

示例13: initAnimation

import android.animation.ValueAnimator; //導入方法依賴的package包/類
/**
 * 進度移動動畫  通過插值的方式改變移動的距離
 */
private void initAnimation() {
   progressAnimator = ValueAnimator.ofFloat(0, mProgress);
    progressAnimator.setDuration(duration);
    progressAnimator.setStartDelay(startDelay);
    progressAnimator.setInterpolator(new LinearInterpolator());
    progressAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator valueAnimator) {
            float value = (float) valueAnimator.getAnimatedValue();
            //進度數值隻顯示整數,我們自己的需求,可以忽略
            textString = formatNum(format2Int(value));
            //把當前百分比進度轉化成view寬度對應的比例
            currentProgress = value * mWidth / 100;
            //進度回調方法
            if (progressListener != null) {
                progressListener.currentProgressListener(value);
            }
            //移動百分比提示框,隻有當前進度到提示框中間位置之後開始移動,
            //當進度框移動到最右邊的時候停止移動,但是進度條還可以繼續移動
            //moveDis是tip框移動的距離
            if (currentProgress >= (tipWidth / 2) &&
                    currentProgress <= (mWidth - tipWidth / 2)) {
                moveDis = currentProgress - tipWidth / 2;
            }
            invalidate();
        }
    });
    progressAnimator.start();
   /* int ssss=mWidth;
      currentProgress = mProgress / 100 * mWidth;  //這個是進行顯示的進度  60%
    invalidate();*/
}
 
開發者ID:songjiabin,項目名稱:MySelfDemo,代碼行數:36,代碼來源:HorizontalProgressBar.java

示例14: startSuccessSymbolAnim

import android.animation.ValueAnimator; //導入方法依賴的package包/類
/**
 * 開始加載成功動畫
 */
private void startSuccessSymbolAnim() {
    currentPath.reset();
    pathMeasure.setPath(successSymbolPath, false);
    pathMeasure.getPosTan(0, mCurrentPosition, null);
    currentPath.moveTo(mCurrentPosition[0], mCurrentPosition[1]);

    ValueAnimator valueAnimator = ValueAnimator.ofFloat(0, pathMeasure.getLength());
    valueAnimator.setDuration(500);
    // 減速插值器
    valueAnimator.setInterpolator(new DecelerateInterpolator());
    valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            if (isLoading)
                return;
            float value = (Float) animation.getAnimatedValue();
            // 獲取當前點坐標封裝到mCurrentPosition
            float[] tmp = mCurrentPosition;
            pathMeasure.getPosTan(value, mCurrentPosition, null);
            currentPath.quadTo(tmp[0], tmp[1], mCurrentPosition[0], mCurrentPosition[1]);
            invalidateCallback.redraw();
        }
    });
    valueAnimator.start();
}
 
開發者ID:CuiZhaoHui,項目名稱:LoadingViews,代碼行數:30,代碼來源:ChaseLoading.java

示例15: upAndCancelEvent

import android.animation.ValueAnimator; //導入方法依賴的package包/類
private void upAndCancelEvent() {
    if (isInCircle && mDistanceCircles == 0) {
        reset();
        if (mOnPointDragListener != null) {
            mOnPointDragListener.onRecovery(this);
        }
    } else if (!mIsDragOut) {
        mCenterCircleCopy.set(mCenterCircle.x, mCenterCircle.y);
        mDragCircleCopy.set(mDragCircle.x, mDragCircle.y);
        if (mRecoveryAnim == null) {
            mRecoveryAnim = ValueAnimator.ofFloat(1.f, -Math.abs(mRecoveryAnimBounce));
            mRecoveryAnim.setDuration(mRecoveryAnimDuration);
            mRecoveryAnim.addUpdateListener(this);
            mRecoveryAnim.addListener(this);
        }
        if (mRecoveryAnimInterpolator != null)
            mRecoveryAnim.setInterpolator(mRecoveryAnimInterpolator);
        mRecoveryAnim.start();
    } else {
        if (mDistanceCircles <= mMaxRadiusTrebling) {
            reset();
            if (mOnPointDragListener != null) {
                mOnPointDragListener.onRecovery(this);
            }
        } else if (!TextUtils.isEmpty(clearSign)) {
            ClearViewHelper.getInstance().clearPointViewBySign(origView, clearSign);
        } else {
            startRemove();
        }
    }
}
 
開發者ID:javonleee,項目名稱:DragPointView,代碼行數:32,代碼來源:DragPointViewWindow.java


注:本文中的android.animation.ValueAnimator.ofFloat方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。