当前位置: 首页>>代码示例>>Java>>正文


Java ValueAnimator.ofObject方法代码示例

本文整理汇总了Java中android.animation.ValueAnimator.ofObject方法的典型用法代码示例。如果您正苦于以下问题:Java ValueAnimator.ofObject方法的具体用法?Java ValueAnimator.ofObject怎么用?Java ValueAnimator.ofObject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.animation.ValueAnimator的用法示例。


在下文中一共展示了ValueAnimator.ofObject方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: animateFilterTo

import android.animation.ValueAnimator; //导入方法依赖的package包/类
private void animateFilterTo(float[] targetFilter) {
    float[] oldFilter = mCurrentFilter == null ? new ColorMatrix().getArray() : mCurrentFilter;
    mCurrentFilter = Arrays.copyOf(oldFilter, oldFilter.length);

    if (mFilterAnimator != null) {
        mFilterAnimator.cancel();
    }
    mFilterAnimator = ValueAnimator.ofObject(new FloatArrayEvaluator(mCurrentFilter),
            oldFilter, targetFilter);
    mFilterAnimator.setDuration(COLOR_CHANGE_DURATION);
    mFilterAnimator.addUpdateListener(new AnimatorUpdateListener() {

        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            mPaint.setColorFilter(new ColorMatrixColorFilter(mCurrentFilter));
            invalidate();
        }
    });
    mFilterAnimator.start();
}
 
开发者ID:enricocid,项目名称:LaunchEnr,代码行数:21,代码来源:DragView.java

示例2: startIncertitudeAnimator

import android.animation.ValueAnimator; //导入方法依赖的package包/类
private void startIncertitudeAnimator() {
    if (mColorAnimator == null) {
        mColorAnimator = ValueAnimator.ofObject(new ArgbEvaluator(), mProgressColor, SkinHelper.getTranColor(mProgressColor, 0x10));
        mColorAnimator.setInterpolator(new LinearInterpolator());
        mColorAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
            @Override
            public void onAnimationUpdate(ValueAnimator animation) {
                drawColor = (int) animation.getAnimatedValue();//之后就可以得到动画的颜色了.
                postInvalidate();
            }
        });
        mColorAnimator.setDuration(1000);
        mColorAnimator.setRepeatCount(ValueAnimator.INFINITE);
        mColorAnimator.setRepeatMode(ValueAnimator.REVERSE);
    }
    mColorAnimator.start();
}
 
开发者ID:angcyo,项目名称:RLibrary,代码行数:18,代码来源:SimpleProgressBar.java

示例3: animateFilterTo

import android.animation.ValueAnimator; //导入方法依赖的package包/类
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private void animateFilterTo(float[] targetFilter) {
    float[] oldFilter = mCurrentFilter == null ? new ColorMatrix().getArray() : mCurrentFilter;
    mCurrentFilter = Arrays.copyOf(oldFilter, oldFilter.length);

    if (mFilterAnimator != null) {
        mFilterAnimator.cancel();
    }
    mFilterAnimator = ValueAnimator.ofObject(new FloatArrayEvaluator(mCurrentFilter),
            oldFilter, targetFilter);
    mFilterAnimator.setDuration(COLOR_CHANGE_DURATION);
    mFilterAnimator.addUpdateListener(new AnimatorUpdateListener() {

        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            mPaint.setColorFilter(new ColorMatrixColorFilter(mCurrentFilter));
            invalidate();
        }
    });
    mFilterAnimator.start();
}
 
开发者ID:TeamBrainStorm,项目名称:SimpleUILauncher,代码行数:22,代码来源:DragView.java

示例4: startWaveAnimation

import android.animation.ValueAnimator; //导入方法依赖的package包/类
/**
 * 动画
 */
private void startWaveAnimation() {
    Point startPoint = new Point(0, START_POSITION);
    Point endPoint = new Point(1920, START_POSITION);
    ValueAnimator anim = ValueAnimator.ofObject(new PointEvaluator(), startPoint, endPoint);
    anim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            currentPoint = (Point) animation.getAnimatedValue();
            invalidate();
        }
    });
    anim.setInterpolator(new LinearInterpolator());
    anim.setDuration(duration);
    anim.setRepeatMode(ValueAnimator.RESTART);
    anim.setRepeatCount(Animation.INFINITE);
    anim.start();
}
 
开发者ID:NickKJ,项目名称:WavesView,代码行数:21,代码来源:WaveViewDraw.java

示例5: onClick

import android.animation.ValueAnimator; //导入方法依赖的package包/类
@Override
public void onClick(View v) {
    ValueAnimator valueAnimator = ValueAnimator.ofObject(new CirclePointEvaluator(), new Point(mStartXPoint, mStartYPoint),
            new Point(mEndXPoint, mEndYPoint));
    valueAnimator.setDuration(600);
    valueAnimator.setInterpolator(new AccelerateDecelerateInterpolator());
    valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            Point point = (Point) animation.getAnimatedValue();
            mMoveXPoint = point.x;
            mMoveYPoint = point.y;
            invalidate();
        }
    });
    valueAnimator.start();

}
 
开发者ID:Lichenwei-Dev,项目名称:BezierView,代码行数:19,代码来源:BezierMoveView.java

示例6: locationChangeAnimate

import android.animation.ValueAnimator; //导入方法依赖的package包/类
/**
 * Handles the animation from currentSourcePoint to the new user location point.
 */
private void locationChangeAnimate(@NonNull Point currentSourcePoint, @NonNull Point newPoint) {
  if (locationChangeAnimator != null) {
    locationChangeAnimator.end();
  }

  locationChangeAnimator = ValueAnimator.ofObject(new Utils.PointEvaluator(), currentSourcePoint,
    newPoint);
  locationChangeAnimator.setDuration(linearAnimation || (location.getSpeed() > 0)
    ? getLocationUpdateDuration() : LocationLayerConstants.LOCATION_UPDATE_DELAY_MS);
  if (linearAnimation || location.getSpeed() > 0) {
    locationChangeAnimator.setInterpolator(new LinearInterpolator());
  } else {
    locationChangeAnimator.setInterpolator(new AccelerateDecelerateInterpolator());
  }
  locationChangeAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
    @Override
    public void onAnimationUpdate(ValueAnimator animation) {
      previousPoint = (Point) animation.getAnimatedValue();
      locationLayer.setLocationPoint(previousPoint);
    }
  });
  locationChangeAnimator.start();
}
 
开发者ID:mapbox,项目名称:mapbox-plugins-android,代码行数:27,代码来源:LocationLayerPlugin.java

示例7: 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:ZhuoKeTeam,项目名称:JueDiQiuSheng,代码行数:20,代码来源:ElectricFanLoadingRenderer.java

示例8: CommonTabLayout

import android.animation.ValueAnimator; //导入方法依赖的package包/类
public CommonTabLayout(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    setWillNotDraw(false);//重写onDraw方法,需要调用这个方法来清除flag
    setClipChildren(false);
    setClipToPadding(false);

    this.mContext = context;
    mTabsContainer = new LinearLayout(context);
    addView(mTabsContainer);

    obtainAttributes(context, attrs);

    //get layout_height
    String height = attrs.getAttributeValue("http://schemas.android.com/apk/res/android", "layout_height");

    //create ViewPager
    if (height.equals(ViewGroup.LayoutParams.MATCH_PARENT + "")) {
    } else if (height.equals(ViewGroup.LayoutParams.WRAP_CONTENT + "")) {
    } else {
        int[]      systemAttrs = {android.R.attr.layout_height};
        TypedArray a           = context.obtainStyledAttributes(attrs, systemAttrs);
        mHeight = a.getDimensionPixelSize(0, ViewGroup.LayoutParams.WRAP_CONTENT);
        a.recycle();
    }

    mValueAnimator = ValueAnimator.ofObject(new PointEvaluator(), mLastP, mCurrentP);
    mValueAnimator.addUpdateListener(this);
}
 
开发者ID:ynztlxdeai,项目名称:MVPtemplate,代码行数:29,代码来源:CommonTabLayout.java

示例9: SegmentTabLayout

import android.animation.ValueAnimator; //导入方法依赖的package包/类
public SegmentTabLayout(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    setWillNotDraw(false);//重写onDraw方法,需要调用这个方法来清除flag
    setClipChildren(false);
    setClipToPadding(false);

    this.mContext = context;
    mTabsContainer = new LinearLayout(context);
    addView(mTabsContainer);

    obtainAttributes(context, attrs);

    //get layout_height
    String height = attrs.getAttributeValue("http://schemas.android.com/apk/res/android", "layout_height");

    //create ViewPager
    if (height.equals(ViewGroup.LayoutParams.MATCH_PARENT + "")) {
    } else if (height.equals(ViewGroup.LayoutParams.WRAP_CONTENT + "")) {
    } else {
        int[] systemAttrs = {android.R.attr.layout_height};
        TypedArray a = context.obtainStyledAttributes(attrs, systemAttrs);
        mHeight = a.getDimensionPixelSize(0, ViewGroup.LayoutParams.WRAP_CONTENT);
        a.recycle();
    }

    mValueAnimator = ValueAnimator.ofObject(new PointEvaluator(), mLastP, mCurrentP);
    mValueAnimator.addUpdateListener(this);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:29,代码来源:SegmentTabLayout.java

示例10: start

import android.animation.ValueAnimator; //导入方法依赖的package包/类
private void start() {
    if (!isEnableAnim) { // 禁止动画
        if (useCommaFormat) {
            setText(mPrefixString + format(new BigDecimal(mNumEnd)) + mPostfixString);
        } else {
            setText(mPrefixString + mNumEnd + mPostfixString);
        }
        return;
    }
    if (runWhenChange) {
        if (preStr.equals(mNumEnd)) {
            //如果两次内容一致,则不做处理
            setText(mNumEnd);
            return;
        }
        preStr = mNumEnd;//如果两次内容不一致,记录最新的str
    }
    ValueAnimator animator = ValueAnimator.ofObject(new BigDecimalEvaluator(), new BigDecimal(mNumStart), new BigDecimal(mNumEnd));
    animator.setDuration(mDuration);
    animator.setInterpolator(new AccelerateDecelerateInterpolator());
    animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator valueAnimator) {
            BigDecimal value = (BigDecimal) valueAnimator.getAnimatedValue();
            setText(mPrefixString + format(value) + mPostfixString);
        }
    });
    animator.start();
}
 
开发者ID:yiwent,项目名称:ShiftyTextview,代码行数:30,代码来源:ShiftyTextview.java

示例11: animateFailedSet

import android.animation.ValueAnimator; //导入方法依赖的package包/类
/**
 * Change card color. This method wraps the Property Animation API mentioned here
 * https://stackoverflow.com/a/14467625/7009268
 */
public void animateFailedSet() {
    int colorFrom = ContextCompat.getColor(getContext(), R.color.card_background_normal);
    int colorTo = ContextCompat.getColor(getContext(), R.color.fbutton_color_carrot);
    final SetGameCardView card = this;

    int duration = getContext().getResources().getInteger(R.integer.card_fail_animation_duration_flash);

    ValueAnimator colorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), colorFrom, colorTo);
    colorAnimation.setDuration(duration); // milliseconds
    colorAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator animator) {
            card.setCardBackgroundColor((int) animator.getAnimatedValue());
        }
    });
    colorAnimation.setRepeatMode(ValueAnimator.REVERSE);
    colorAnimation.setRepeatCount(2);
    colorAnimation.start();

    colorAnimation.addListener(new AnimatorListenerAdapter()
    {
        @Override
        public void onAnimationEnd(Animator animation)
        {
            // Once animation is over, animate back to selected or highlighted or normal
            card.setChecked(false, false);
            if (isHighlighted()) {
                animateColorChange(R.color.fbutton_color_alizarin, R.color.card_background_highlighted);
            } else {
                animateColorChange(R.color.fbutton_color_alizarin, R.color.card_background_normal);
            }
        }
    });
}
 
开发者ID:jaysondc,项目名称:TripleTap,代码行数:39,代码来源:SetGameCardView.java

示例12: CommonTabLayout

import android.animation.ValueAnimator; //导入方法依赖的package包/类
public CommonTabLayout(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    setWillNotDraw(false);//重写onDraw方法,需要调用这个方法来清除flag
    setClipChildren(false);
    setClipToPadding(false);

    this.mContext = context;
    mTabsContainer = new LinearLayout(context);
    addView(mTabsContainer);

    obtainAttributes(context, attrs);

    //get layout_height
    String height = attrs.getAttributeValue("http://schemas.android.com/apk/res/android", "layout_height");

    //create ViewPager
    if (height.equals(ViewGroup.LayoutParams.MATCH_PARENT + "")) {
    } else if (height.equals(ViewGroup.LayoutParams.WRAP_CONTENT + "")) {
    } else {
        int[] systemAttrs = {android.R.attr.layout_height};
        TypedArray a = context.obtainStyledAttributes(attrs, systemAttrs);
        mHeight = a.getDimensionPixelSize(0, ViewGroup.LayoutParams.WRAP_CONTENT);
        a.recycle();
    }

    mValueAnimator = ValueAnimator.ofObject(new PointEvaluator(), mLastP, mCurrentP);
    mValueAnimator.addUpdateListener(this);
}
 
开发者ID:yangjiantao,项目名称:AndroidUiKit,代码行数:29,代码来源:CommonTabLayout.java

示例13: startAnim

import android.animation.ValueAnimator; //导入方法依赖的package包/类
public void startAnim() {
    RectF startRect = new RectF(targetSize.centerX(), targetSize.centerY(), targetSize.centerX(), targetSize.centerY());
    ValueAnimator rectSize = ValueAnimator.ofObject(new RectFEvaluator(), startRect, targetSize);
    rectSize.setDuration(animDuration);
    rectSize.setInterpolator(new QuintOut());
    rectSize.setStartDelay(startDelay);
    rectSize.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            drawingRect = (RectF) animation.getAnimatedValue();
            invalidate();
        }
    });
    rectSize.start();
}
 
开发者ID:MSay2,项目名称:Mire,代码行数:16,代码来源:CircularSplashView.java

示例14: animateRevealHide

import android.animation.ValueAnimator; //导入方法依赖的package包/类
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public void animateRevealHide(final View viewRoot) {
    View fab = MainActivity.of(getActivity()).fab;
    int cx = fab.getLeft() + (fab.getWidth()/2); //middle of button
    int cy = fab.getTop() + (fab.getHeight()/2); //middle of button
    int radius = (int) Math.sqrt(Math.pow(cx, 2) + Math.pow(cy, 2)); //hypotenuse to top left

    Animator anim = ViewAnimationUtils.createCircularReveal(viewRoot, cx, cy, radius, 0);
    anim.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            super.onAnimationEnd(animation);
            viewRoot.setVisibility(View.INVISIBLE);
        }
    });
    //anim.setInterpolator(new AccelerateInterpolator());
    anim.setDuration(Navigator.ANIM_DURATION);
    anim.start();

    Integer colorTo = getResources().getColor(R.color.primaryColor);
    Integer colorFrom = getResources().getColor(android.R.color.white);
    ValueAnimator colorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), colorFrom, colorTo);
    colorAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator animator) {
            overlayLayout.setBackgroundColor((Integer)animator.getAnimatedValue());
        }

    });
    colorAnimation.setInterpolator(new AccelerateInterpolator(2));
    colorAnimation.setDuration(Navigator.ANIM_DURATION);
    colorAnimation.start();
}
 
开发者ID:shenhuanet,项目名称:AndroidOpen,代码行数:34,代码来源:OverlayFragment.java

示例15: setAnimator

import android.animation.ValueAnimator; //导入方法依赖的package包/类
private static ValueAnimator setAnimator(int colorFrom, int colorTo) {
    ValueAnimator colorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), colorFrom, colorTo);
    long duration = 300;
    colorAnimation.setDuration(duration);
    return colorAnimation;
}
 
开发者ID:RajneeshSingh007,项目名称:MusicX-music-player,代码行数:7,代码来源:Helper.java


注:本文中的android.animation.ValueAnimator.ofObject方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。