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


Java ValueAnimator類代碼示例

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


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

示例1: 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

示例2: AlbumPictureController

import android.animation.ValueAnimator; //導入依賴的package包/類
public AlbumPictureController(Context context, final ImageSwitcher view, int size) {
    this.view = view;
    this.size = size;
    this.context = context;
    this.cache = new BitmapCache(context, BitmapCache.CACHE_ALBUM_VISUALIZER_IMAGE);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        defaultColor = context.getColor(R.color.default_play_bg_color);
        defaultTextColor = context.getColor(R.color.default_play_text_color);
    } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        defaultColor = context.getResources().getColor(R.color.default_play_bg_color, null);
        defaultTextColor = context.getResources().getColor(R.color.default_play_text_color, null);
    } else {
        defaultColor = context.getResources().getColor(R.color.default_play_bg_color);
        defaultTextColor = context.getResources().getColor(R.color.default_play_text_color);
    }

    this.bitmapProducer = new BitmapProducer(context);

    colors = new int[]{
            defaultColor,
            defaultTextColor,
            defaultColor,
            defaultTextColor
    };

    rotateAnim = ObjectAnimator.ofFloat(0, 360);
    rotateAnim.setDuration(45 * 1000);
    rotateAnim.setRepeatMode(ValueAnimator.RESTART);
    rotateAnim.setRepeatCount(ValueAnimator.INFINITE);
    rotateAnim.setInterpolator(new LinearInterpolator());
    rotateAnim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            float value = (float) animation.getAnimatedValue();
            view.getCurrentView().setRotation(value);
        }
    });
}
 
開發者ID:DuanJiaNing,項目名稱:Musicoco,代碼行數:40,代碼來源:AlbumPictureController.java

示例3: createAnimation

import android.animation.ValueAnimator; //導入依賴的package包/類
@Override
public List<Animator> createAnimation() {
    List<Animator> animators=new ArrayList<>();

    int[] durations={960, 930, 1190, 1130, 1340, 940, 1200, 820, 1190};
    int[] delays= {360, 400, 680, 410, 710, -150, -120, 10, 320};

    for (int i = 0; i < 9; i++) {
        final int index=i;
        ValueAnimator alphaAnim=ValueAnimator.ofInt(255, 168,255);
        alphaAnim.setDuration(durations[i]);
        alphaAnim.setRepeatCount(-1);
        alphaAnim.setStartDelay(delays[i]);
        alphaAnim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
            @Override
            public void onAnimationUpdate(ValueAnimator animation) {
                alphas[index] = (int) animation.getAnimatedValue();
                postInvalidate();
            }
        });
        alphaAnim.start();
        animators.add(alphaAnim);
    }
    return animators;
}
 
開發者ID:Mrqinlei,項目名稱:ImitateZHRB,代碼行數:26,代碼來源:BallGridBeatIndicator.java

示例4: 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:Vinetos,項目名稱:Hello-Music-droid,代碼行數:27,代碼來源:PlayPauseButton.java

示例5: 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

示例6: upEventDeal

import android.animation.ValueAnimator; //導入依賴的package包/類
/**
 * ACTION_UP/ACTION_CANCEL事件處理方法
 */
private void upEventDeal() {
    // 1.回調手勢解鎖監聽器Complete方法
    if (mGestureLockListener != null) {
        mGestureLockListener.onComplete(getPassword());
    }
    // 2.清除觸摸點到最後按下單元點的連線
    if (!mPressPoints.isEmpty()) {
        mEventX = mPressPoints.get(mPressPoints.size() - 1).x;
        mEventY = mPressPoints.get(mPressPoints.size() - 1).y;
    }
    // 3.提前結束未執行完的動畫
    if (!mPointAnimators.isEmpty()) {
        for (ValueAnimator animator : mPointAnimators) {
            animator.end();
        }
        mPointAnimators.clear();
    }
    // 4.重繪
    postInvalidate();
}
 
開發者ID:sinawangnan7,項目名稱:GestureLockView,代碼行數:24,代碼來源:GestureLockView.java

示例7: endAnimation

import android.animation.ValueAnimator; //導入依賴的package包/類
@Override
public void endAnimation(DynamicWeatherView dynamicWeatherView, Animator.AnimatorListener listener) {
    super.endAnimation(dynamicWeatherView, listener);
    ValueAnimator animator = ValueAnimator.ofFloat(getWidth() - bitmap.getWidth() * 0.25f, getWidth());
    animator.setDuration(1000);
    animator.setRepeatCount(0);
    animator.setInterpolator(new AccelerateInterpolator());
    animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            transFactor = (float) animation.getAnimatedValue();
        }
    });
    if (listener != null) {
        animator.addListener(listener);
    }
    animator.start();
}
 
開發者ID:li-yu,項目名稱:FakeWeather,代碼行數:19,代碼來源:HailType.java

示例8: startSunRotate

import android.animation.ValueAnimator; //導入依賴的package包/類
private void startSunRotate() {
    ValueAnimator rotateAnim=animMap.get(ANIM_SUN_ROTATE);
    if (rotateAnim==null){
        rotateAnim =ValueAnimator.ofFloat(0,360f).setDuration(30*1000);
        rotateAnim.setRepeatCount(ValueAnimator.INFINITE);
        rotateAnim.setInterpolator(new LinearInterpolator());
        rotateAnim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
            @Override
            public void onAnimationUpdate(ValueAnimator animation) {
                sunRotateAngle= (float) animation.getAnimatedValue();
            }
        });
        animMap.put(ANIM_SUN_ROTATE,rotateAnim);
    }
    startValueAnimator(rotateAnim);
}
 
開發者ID:Zweihui,項目名稱:Aurora,代碼行數:17,代碼來源:WeatherView.java

示例9: createAnimation

import android.animation.ValueAnimator; //導入依賴的package包/類
@Override
public List<Animator> createAnimation() {
    List<Animator> animators=new ArrayList<>();
    long[] delays=new long[]{400,200,0,200,400};
    for (int i = 0; i < 5; i++) {
        final int index=i;
        ValueAnimator scaleAnim=ValueAnimator.ofFloat(1,0.4f,1);
        scaleAnim.setDuration(1000);
        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:zhouphenix,項目名稱:Multi-SwipeToRefreshLayout,代碼行數:23,代碼來源:LineScalePulseOutRapidIndicator.java

示例10: startAnim

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

        rb_start.setVisibility(View.GONE);
        ValueAnimator va = ValueAnimator.ofFloat(0, dp100).setDuration(300);
        va.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
            @Override
            public void onAnimationUpdate(ValueAnimator animation) {

                float value = (float) animation.getAnimatedValue();
                float dis = value-lastValue;
                iv_back.setX(iv_back.getX()-dis);
                iv_finish.setX(iv_finish.getX()+dis);
                lastValue = value;
            }
        });
        va.start();
    }
 
開發者ID:Zhaoss,項目名稱:WeiXinRecordedDemo,代碼行數:18,代碼來源:MainActivity.java

示例11: createAnimators

import android.animation.ValueAnimator; //導入依賴的package包/類
private void createAnimators() {
    mAnimators = new ArrayList<>();
    int[] delays = new int[]{120, 240, 360};
    for (int i = 0; i < 3; i++) {
        final int index = i;

        ValueAnimator scaleAnim = ValueAnimator.ofFloat(1, 0.3f, 1);

        scaleAnim.setDuration(750);
        scaleAnim.setRepeatCount(ValueAnimator.INFINITE);
        scaleAnim.setStartDelay(delays[i]);

        mUpdateListeners.put(scaleAnim, new ValueAnimator.AnimatorUpdateListener() {
            @Override
            public void onAnimationUpdate(ValueAnimator animation) {
                scaleFloats[index] = (float) animation.getAnimatedValue();
                postInvalidate();
            }
        });
        mAnimators.add(scaleAnim);
    }
}
 
開發者ID:Justson,項目名稱:AgentWebX5,代碼行數:23,代碼來源:BallPulseView.java

示例12: startBackAnimator

import android.animation.ValueAnimator; //導入依賴的package包/類
/**
 * 啟動動畫 回彈效果
 *
 */
private void startBackAnimator() {
    PropertyValuesHolder xValuesHolder = PropertyValuesHolder.ofFloat("x", canvasRotateX, 0);
    PropertyValuesHolder yValuesHolder = PropertyValuesHolder.ofFloat("y", canvasRotateY, 0);
    touchAnimator = ValueAnimator.ofPropertyValuesHolder(xValuesHolder, yValuesHolder).setDuration(700);
    touchAnimator.setInterpolator(new BounceInterpolator());
    touchAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            canvasRotateY = (Float) animation.getAnimatedValue("y");
            canvasRotateX = (Float) animation.getAnimatedValue("x");
            invalidate();
        }
    });
    touchAnimator.start();
}
 
開發者ID:aohanyao,項目名稱:SafeView,代碼行數:20,代碼來源:SafeView.java

示例13: onCreateAnimators

import android.animation.ValueAnimator; //導入依賴的package包/類
@Override
public ArrayList<ValueAnimator> onCreateAnimators() {
    ArrayList<ValueAnimator> animators = new ArrayList<>();
    int[] delays = new int[]{120, 240, 360};
    for (int i = 0; i < 3; i++) {
        final int index = i;

        ValueAnimator scaleAnim = ValueAnimator.ofFloat(1, 0.3f, 1);

        scaleAnim.setDuration(750);
        scaleAnim.setRepeatCount(-1);
        scaleAnim.setStartDelay(delays[i]);

        addUpdateListener(scaleAnim, animation -> {
            scaleFloats[index] = (float) animation.getAnimatedValue();
            postInvalidate();
        });
        animators.add(scaleAnim);
    }
    return animators;
}
 
開發者ID:7763sea,項目名稱:VirtualHook,代碼行數:22,代碼來源:BallPulseIndicator.java

示例14: setupValues

import android.animation.ValueAnimator; //導入依賴的package包/類
public UDAnimatorSet setupValues(Animator animator) {
    animator.setupStartValues();
    if (mTarget != null && mAnimators != null) {
        for (Animator anim : mAnimators) {
            anim.setTarget(mTarget.getView());
            anim.setupStartValues();
            if (anim instanceof ValueAnimator) {
                ((ValueAnimator) anim).setRepeatCount(mRepeatCount);
                ((ValueAnimator) anim).setRepeatMode(mRepeatMode);
                //TODO
            }
        }
        if (animator instanceof AnimatorSet) {
            ((AnimatorSet) animator).playTogether(mAnimators);
        }
    }
    return this;
}
 
開發者ID:alibaba,項目名稱:LuaViewPlayground,代碼行數:19,代碼來源:UDAnimatorSet.java

示例15: getBezierValueAnimator

import android.animation.ValueAnimator; //導入依賴的package包/類
private ValueAnimator getBezierValueAnimator(LeafHolder target, RectF leafFlyRect, float progress) {
    BezierEvaluator evaluator = new BezierEvaluator(getPoint1(leafFlyRect), getPoint2(leafFlyRect));

    int leafFlyStartY = (int) (mCurrentProgressBounds.bottom - mLeafDrawable.getIntrinsicHeight());
    int leafFlyRange = (int) (mCurrentProgressBounds.height() - mLeafDrawable.getIntrinsicHeight());

    int startPointY = leafFlyStartY - mRandom.nextInt(leafFlyRange);
    int endPointY = leafFlyStartY - mRandom.nextInt(leafFlyRange);

    ValueAnimator animator = ValueAnimator.ofObject(evaluator,
            new PointF((int) (leafFlyRect.right - mLeafDrawable.getIntrinsicWidth()), startPointY),
            new PointF(leafFlyRect.left, endPointY));
    animator.addUpdateListener(new BezierListener(target));
    animator.setTarget(target);

    animator.setDuration((long) ((mRandom.nextInt(300) + mDuration * DEFAULT_LEAF_FLY_DURATION_FACTOR) * (1.0f - progress)));

    return animator;
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:20,代碼來源:ElectricFanLoadingRenderer.java


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