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


Java ObjectAnimator.ofPropertyValuesHolder方法代碼示例

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


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

示例1: createHideItemAnimator

import android.animation.ObjectAnimator; //導入方法依賴的package包/類
private Animator createHideItemAnimator(final View item) {
        float dx = fab.getX() - item.getX();
        float dy = fab.getY() - item.getY();

        Animator anim = ObjectAnimator.ofPropertyValuesHolder(
                item,
//                AnimatorUtils.rotation(720f, 0f),
                AnimatorUtils.translationX(0f, dx),
                AnimatorUtils.translationY(0f, dy)
        );

        anim.addListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationEnd(Animator animation) {
                super.onAnimationEnd(animation);
                item.setTranslationX(0f);
                item.setTranslationY(0f);
            }
        });

        return anim;
    }
 
開發者ID:xzg8023,項目名稱:ArcLayout-master,代碼行數:23,代碼來源:MainActivity.java

示例2: getPulseAnimator

import android.animation.ObjectAnimator; //導入方法依賴的package包/類
/**
 * Render an animator to pulsate a view in place.
 *
 * @param labelToAnimate the view to pulsate.
 * @return The animator object. Use .start() to begin.
 */
public static ObjectAnimator getPulseAnimator(View labelToAnimate, float decreaseRatio,
                                              float increaseRatio) {
    Keyframe k0 = Keyframe.ofFloat(0f, 1f);
    Keyframe k1 = Keyframe.ofFloat(0.275f, decreaseRatio);
    Keyframe k2 = Keyframe.ofFloat(0.69f, increaseRatio);
    Keyframe k3 = Keyframe.ofFloat(1f, 1f);

    @SuppressLint("ObjectAnimatorBinding") PropertyValuesHolder scaleX = PropertyValuesHolder.ofKeyframe("scaleX", k0, k1, k2, k3);
    @SuppressLint("ObjectAnimatorBinding") PropertyValuesHolder scaleY = PropertyValuesHolder.ofKeyframe("scaleY", k0, k1, k2, k3);
    ObjectAnimator pulseAnimator =
            ObjectAnimator.ofPropertyValuesHolder(labelToAnimate, scaleX, scaleY);
    pulseAnimator.setDuration(PULSE_ANIMATOR_DURATION);

    return pulseAnimator;
}
 
開發者ID:ttpho,項目名稱:TimePicker,代碼行數:22,代碼來源:Utils.java

示例3: buildAnimation

import android.animation.ObjectAnimator; //導入方法依賴的package包/類
@Override
public Animator buildAnimation(@NonNull ViewDefault viewDefault, @NonNull View viewToMorph, boolean isReversed) {
    if (!isReversed) {
        initialAlpha = viewDefault.getAlpha();
    }
    float alphaValue = isReversed ? initialAlpha : targetAlpha;
    alphaValue = alphaValue < 0 ? 0 : alphaValue;
    alphaValue = alphaValue > 1 ? 1 : alphaValue;
    viewDefault.setAlpha(alphaValue);
    PropertyValuesHolder[] parameters = new PropertyValuesHolder[1];
    parameters[0] = PropertyValuesHolder.ofFloat(View.ALPHA, alphaValue);
    ObjectAnimator animator = ObjectAnimator.ofPropertyValuesHolder(viewToMorph, parameters);
    if (duration >= 0) {
        animator.setDuration(duration);
    }
    if (interpolator != null) {
        animator.setInterpolator(interpolator);
    }
    return animator;
}
 
開發者ID:rjsvieira,項目名稱:morphos,代碼行數:21,代碼來源:AlphaAnimation.java

示例4: apply

import android.animation.ObjectAnimator; //導入方法依賴的package包/類
@Override
public SkinAnimator apply(@NonNull final View view, @Nullable final Action action) {
    animator = ObjectAnimator.ofPropertyValuesHolder(view,
            PropertyValuesHolder.ofFloat("alpha", 1, 0)
    );
    animator.setDuration(3 * PRE_DURATION);
    animator.setInterpolator(new LinearInterpolator());
    animator.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            super.onAnimationEnd(animation);
            resetView(view);
            if (action != null) {
                action.action();
            }
        }
    });
    return this;
}
 
開發者ID:wutongke,項目名稱:AndroidSkinAnimator,代碼行數:20,代碼來源:AlphaHideAnimator.java

示例5: apply

import android.animation.ObjectAnimator; //導入方法依賴的package包/類
@Override
public SkinAnimator apply(@NonNull final View view, @Nullable final Action action) {
    animator = ObjectAnimator.ofPropertyValuesHolder(view,
            PropertyValuesHolder.ofFloat("alpha", 1, 0),
            PropertyValuesHolder.ofFloat("translationX", view.getLeft(), view.getRight()));
    animator.setDuration(3 * PRE_DURATION);
    animator.setInterpolator(new AnticipateInterpolator());
    animator.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            super.onAnimationEnd(animation);
            resetView(view);
            if (action != null) {
                action.action();
            }
        }
    });
    return this;
}
 
開發者ID:wutongke,項目名稱:AndroidSkinAnimator,代碼行數:20,代碼來源:TranslationHideAnimator.java

示例6: onDisappear

import android.animation.ObjectAnimator; //導入方法依賴的package包/類
@Override
public Animator onDisappear(ViewGroup sceneRoot, View view, TransitionValues startValues,
                            TransitionValues endValues) {
    return ObjectAnimator.ofPropertyValuesHolder(
            view,
            PropertyValuesHolder.ofFloat(View.ALPHA, 0f),
            PropertyValuesHolder.ofFloat(View.SCALE_X, 0f),
            PropertyValuesHolder.ofFloat(View.SCALE_Y, 0f));
}
 
開發者ID:alphater,項目名稱:garras,代碼行數:10,代碼來源:Pop.java

示例7: animateMenuClosing

import android.animation.ObjectAnimator; //導入方法依賴的package包/類
@Override
public void animateMenuClosing(Point center) {
    super.animateMenuOpening(center);

    setAnimating(true);

    Animator lastAnimation = null;
    for (int i = 0; i < menu.getSubActionItems().size(); i++) {
        PropertyValuesHolder pvhX = PropertyValuesHolder.ofFloat(View.TRANSLATION_X, - (menu.getSubActionItems().get(i).x - center.x + menu.getSubActionItems().get(i).width / 2));
        PropertyValuesHolder pvhY = PropertyValuesHolder.ofFloat(View.TRANSLATION_Y, - (menu.getSubActionItems().get(i).y - center.y + menu.getSubActionItems().get(i).height / 2));
        PropertyValuesHolder pvhR = PropertyValuesHolder.ofFloat(View.ROTATION, -720);
        PropertyValuesHolder pvhsX = PropertyValuesHolder.ofFloat(View.SCALE_X, 0);
        PropertyValuesHolder pvhsY = PropertyValuesHolder.ofFloat(View.SCALE_Y, 0);
        PropertyValuesHolder pvhA = PropertyValuesHolder.ofFloat(View.ALPHA, 0);

        final ObjectAnimator animation = ObjectAnimator.ofPropertyValuesHolder(menu.getSubActionItems().get(i).view, pvhX, pvhY, pvhR, pvhsX, pvhsY, pvhA);
        animation.setDuration(DURATION);
        animation.setInterpolator(new AccelerateDecelerateInterpolator());
        animation.addListener(new SubActionItemAnimationListener(menu.getSubActionItems().get(i), ActionType.CLOSING));

        if(i == 0) {
            lastAnimation = animation;
        }

        animation.setStartDelay((menu.getSubActionItems().size() - i) * LAG_BETWEEN_ITEMS);
        animation.start();
    }
    if(lastAnimation != null) {
        lastAnimation.addListener(new LastAnimationListener());
    }
}
 
開發者ID:HitRoxxx,項目名稱:FloatingNew,代碼行數:32,代碼來源:DefaultAnimationHandler.java

示例8: initAnim

import android.animation.ObjectAnimator; //導入方法依賴的package包/類
private void initAnim() {
    for (int i = 0; i < getChildCount(); i++) {
        View child = getChildAt(i);
        float transX = (float) ((i + 1) * 0.06);
        float transY = (float) ((i + 1) * 0.12);
        ObjectAnimator animator;

        PropertyValuesHolder valuesHolderX = PropertyValuesHolder.ofFloat("XFraction", 0, transX);
        PropertyValuesHolder valuesHolderY = PropertyValuesHolder.ofFloat("YFraction", 0, transY);
        animator = ObjectAnimator.ofPropertyValuesHolder(child, valuesHolderX, valuesHolderY);
        animator.setInterpolator(mInterpolator);
        animator.setDuration(300);
        mOpenAnimators[i] = animator;

        PropertyValuesHolder valuesHolderXReverse = PropertyValuesHolder.ofFloat("XFraction", transX, 1);
        animator = ObjectAnimator.ofPropertyValuesHolder(child, valuesHolderXReverse);
        animator.setInterpolator(mInterpolator);
        animator.setDuration(300);
        mChosenAnimators[i] = animator;

        PropertyValuesHolder valuesHolderAlpha = PropertyValuesHolder.ofFloat("menuAlpha", 1, 0);
        animator = ObjectAnimator.ofPropertyValuesHolder(child, valuesHolderAlpha);
        animator.setInterpolator(mInterpolator);
        animator.setDuration(300);
        mMenuOpenAnimators[i] = animator;
    }
}
 
開發者ID:zongkaili,項目名稱:MenuSet,代碼行數:28,代碼來源:CoolMenuFrameLayout.java

示例9: createNewTabOpenedAnimator

import android.animation.ObjectAnimator; //導入方法依賴的package包/類
private Animator createNewTabOpenedAnimator(
        StackTab[] tabs, ViewGroup container, TabModel model, int focusIndex) {
    Tab tab = model.getTabAt(focusIndex);
    if (tab == null || !tab.isNativePage()) return null;

    View view = tab.getView();
    if (view == null) return null;

    // Set up the view hierarchy
    if (view.getParent() != null) ((ViewGroup) view.getParent()).removeView(view);
    ViewGroup bgView = new FrameLayout(view.getContext());
    bgView.setBackgroundColor(tab.getBackgroundColor());
    bgView.addView(view);
    container.addView(
            bgView, new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));

    // Update any compositor state that needs to change
    if (tabs != null && focusIndex >= 0 && focusIndex < tabs.length) {
        tabs[focusIndex].setAlpha(0.f);
    }

    // Build the view animations
    PropertyValuesHolder xScale = PropertyValuesHolder.ofFloat(View.SCALE_X, 0.f, 1.f);
    PropertyValuesHolder yScale = PropertyValuesHolder.ofFloat(View.SCALE_Y, 0.f, 1.f);
    PropertyValuesHolder alpha = PropertyValuesHolder.ofFloat(View.ALPHA, 0.f, 1.f);
    ObjectAnimator animator = ObjectAnimator.ofPropertyValuesHolder(
            bgView, xScale, yScale, alpha);

    animator.setDuration(TAB_OPENED_ANIMATION_DURATION);
    animator.setInterpolator(BakedBezierInterpolator.TRANSFORM_FOLLOW_THROUGH_CURVE);

    float insetPx = TAB_OPENED_PIVOT_INSET_DP * mDpToPx;

    bgView.setPivotY(TAB_OPENED_PIVOT_INSET_DP);
    bgView.setPivotX(LocalizationUtils.isLayoutRtl() ? mWidthDp * mDpToPx - insetPx : insetPx);
    return animator;
}
 
開發者ID:rkshuai,項目名稱:chromium-for-android-56-debug-video,代碼行數:38,代碼來源:StackViewAnimation.java

示例10: createAnimator

import android.animation.ObjectAnimator; //導入方法依賴的package包/類
private static @Nullable
ObjectAnimator createAnimator(@NonNull WXAnimationBean animation, final View target) {
  if(target == null){
    return null;
  }
  WXAnimationBean.Style style = animation.styles;
  if (style != null) {
    ObjectAnimator animator;
    List<PropertyValuesHolder> holders =style.getHolders();
    if (!TextUtils.isEmpty(style.backgroundColor)) {
      BorderDrawable borderDrawable;
      if ((borderDrawable=WXViewUtils.getBorderDrawable(target))!=null) {
        holders.add(PropertyValuesHolder.ofObject(
            WXAnimationBean.Style.BACKGROUND_COLOR, new ArgbEvaluator(),
            borderDrawable.getColor(),
            WXResourceUtils.getColor(style.backgroundColor)));
      } else if (target.getBackground() instanceof ColorDrawable) {
        holders.add(PropertyValuesHolder.ofObject(
            WXAnimationBean.Style.BACKGROUND_COLOR, new ArgbEvaluator(),
            ((ColorDrawable) target.getBackground()).getColor(),
            WXResourceUtils.getColor(style.backgroundColor)));
      }
    }
    if (style.getPivot() != null) {
      Pair<Float, Float> pair = style.getPivot();
      target.setPivotX(pair.first);
      target.setPivotY(pair.second);
    }
    animator = ObjectAnimator.ofPropertyValuesHolder(
        target, holders.toArray(new PropertyValuesHolder[holders.size()]));
    animator.setStartDelay(animation.delay);
    final IntEvaluator intEvaluator=new IntEvaluator();
    if (target.getLayoutParams() != null &&
        (!TextUtils.isEmpty(style.width) || !TextUtils.isEmpty(style.height))) {
      DimensionUpdateListener listener = new DimensionUpdateListener(target);
      ViewGroup.LayoutParams layoutParams = target.getLayoutParams();
      if (!TextUtils.isEmpty(style.width)) {
        listener.setWidth(layoutParams.width,
                          (int) WXViewUtils.getRealPxByWidth(WXUtils.getFloat(style.width)));
      }
      if (!TextUtils.isEmpty(style.height)) {
        listener.setHeight(layoutParams.height,
                           (int) WXViewUtils.getRealPxByWidth(WXUtils.getFloat(style.height)));
      }
      animator.addUpdateListener(listener);
    }
    return animator;
  } else {
    return null;
  }
}
 
開發者ID:amap-demo,項目名稱:weex-3d-map,代碼行數:52,代碼來源:WXAnimationModule.java

示例11: createAnimation

import android.animation.ObjectAnimator; //導入方法依賴的package包/類
@Override
public List<Animator> createAnimation() {
    List<Animator> animators=new ArrayList<>();
    PropertyValuesHolder rotation5=PropertyValuesHolder.ofFloat("rotationX",0,180,180,0,0);
    PropertyValuesHolder rotation6=PropertyValuesHolder.ofFloat("rotationY",0,0,180,180,0);
    
    ObjectAnimator animator=ObjectAnimator.ofPropertyValuesHolder(getTarget(), rotation6,rotation5);
    animator.setInterpolator(new LinearInterpolator());
    animator.setRepeatCount(-1);
    animator.setDuration(2500);
    animator.start();

    animators.add(animator);
    return animators;
}
 
開發者ID:leobert-lan,項目名稱:UiLib,代碼行數:16,代碼來源:TriangleSkewSpinIndicator.java

示例12: onFocusChange

import android.animation.ObjectAnimator; //導入方法依賴的package包/類
@Override
public void onFocusChange(View v, boolean hasFocus) {
    if (hasFocus) {
        endCurrentAnimation();

        if (mAlpha > MIN_VISIBLE_ALPHA) {
            mTargetView = v;

            mCurrentAnimation = ObjectAnimator.ofPropertyValuesHolder(this,
                    PropertyValuesHolder.ofFloat(ALPHA, 1),
                    PropertyValuesHolder.ofFloat(SHIFT, 1));
            mCurrentAnimation.addListener(new ViewSetListener(v, true));
        } else {
            setCurrentView(v);

            mCurrentAnimation = ObjectAnimator.ofPropertyValuesHolder(this,
                    PropertyValuesHolder.ofFloat(ALPHA, 1));
        }

        mLastFocusedView = v;
    } else {
        if (mLastFocusedView == v) {
            mLastFocusedView = null;
            endCurrentAnimation();
            mCurrentAnimation = ObjectAnimator.ofPropertyValuesHolder(this,
                    PropertyValuesHolder.ofFloat(ALPHA, 0));
            mCurrentAnimation.addListener(new ViewSetListener(null, false));
        }
    }

    // invalidate once
    invalidateDirty();

    mLastFocusedView = hasFocus ? v : null;
    if (mCurrentAnimation != null) {
        mCurrentAnimation.addUpdateListener(this);
        mCurrentAnimation.setDuration(ANIM_DURATION).start();
    }
}
 
開發者ID:TeamBrainStorm,項目名稱:SimpleUILauncher,代碼行數:40,代碼來源:FocusIndicatorHelper.java

示例13: getRotation

import android.animation.ObjectAnimator; //導入方法依賴的package包/類
private Animator getRotation(AnimationBody animationBody, View view) {
    final float force = animationBody.getForce();

    float[] rotationValues = {
            (float) Math.toDegrees(0),
            (float) Math.toDegrees(0.3f * force),
            (float) Math.toDegrees(-0.3f * force),
            (float) Math.toDegrees(0.3f * force),
            (float) Math.toDegrees(0f),
            (float) Math.toDegrees(0f)
    };

    final PropertyValuesHolder pvhRotation =
            PropertyValuesHolder.ofKeyframe(View.ROTATION, KeyFrameUtil.getKeyFrames(Flubber.FRACTIONS, rotationValues));

    final ObjectAnimator animation =
            ObjectAnimator.ofPropertyValuesHolder(view, pvhRotation);

    animation.setInterpolator(new LinearInterpolator());

    return animation;
}
 
開發者ID:Appolica,項目名稱:Flubber,代碼行數:23,代碼來源:Wobble.java

示例14: getScalingAnimator

import android.animation.ObjectAnimator; //導入方法依賴的package包/類
public ObjectAnimator getScalingAnimator() {
    PropertyValuesHolder imgViewScaleY = PropertyValuesHolder.ofFloat(View
            .SCALE_Y, SCALE_FACTOR);
    PropertyValuesHolder imgViewScaleX = PropertyValuesHolder.ofFloat(View
            .SCALE_X, SCALE_FACTOR);

    ObjectAnimator imgViewScaleAnimator = ObjectAnimator
            .ofPropertyValuesHolder(this, imgViewScaleX, imgViewScaleY);
    imgViewScaleAnimator.setRepeatCount(1);
    imgViewScaleAnimator.setRepeatMode(ValueAnimator.REVERSE);
    imgViewScaleAnimator.setDuration(ANIMATION_DURATION);

    return imgViewScaleAnimator;
}
 
開發者ID:sdrausty,項目名稱:buildAPKsSamples,代碼行數:15,代碼來源:RoundView.java

示例15: suicaRunner

import android.animation.ObjectAnimator; //導入方法依賴的package包/類
protected Runnable suicaRunner(final float x1, final float y1, final float x2, final float y2){
    final float attackTime = 0.9f;
    Runnable runnable = new Runnable() {
        @Override
        public void run() {
            PropertyValuesHolder holderX = PropertyValuesHolder.ofFloat("translationX", x1, x2);
            PropertyValuesHolder holderY = PropertyValuesHolder.ofFloat("translationY", y1, y2);
            PropertyValuesHolder holderRotation = PropertyValuesHolder.ofFloat("rotation", 0, 359);

            ObjectAnimator objectAnimator = ObjectAnimator.ofPropertyValuesHolder(Suica.this, holderX, holderY, holderRotation);
            objectAnimator.setDuration(mTime);
            objectAnimator.start();

            Suica.this.setVisibility(View.VISIBLE);
            mHandler.postDelayed(new Runnable() {
                @Override
                public void run() {
                    if(!mClicked) {
                        Suica.this.setVisibility(View.INVISIBLE);
                        damageButton.callOnClick();
                    }
                }
            }, (int)(mTime * attackTime));
        }
    };
    return  runnable;
}
 
開發者ID:ShitamatsugeFactory,項目名稱:KokoWalk,代碼行數:28,代碼來源:Suica.java


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