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


Java PropertyValuesHolder.ofFloat方法代码示例

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


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

示例1: onTranslateAndFadeWithPropertyValuesHolder

import android.animation.PropertyValuesHolder; //导入方法依赖的package包/类
@OnClick(R.id.translateAndFadeWithPropertyValuesHolder)
public void onTranslateAndFadeWithPropertyValuesHolder() {
    /*
     * https://android-developers.googleblog.com/2011/05/introducing-viewpropertyanimator.html
     * The code above code creates three separate animations and plays them together in an AnimatorSet.
     * This means that there is the processing overhead of setting up the AnimatorSet
     * and running three Animators in parallel to animate these x/y/alpha properties.
     * There is an alternative approach using PropertyValuesHolder that you can use to combine multiple properties inside of one single Animator:
     */
    PropertyValuesHolder pvhX = PropertyValuesHolder.ofFloat("translationX", icon.getTranslationX(), animateForward ? icon.getWidth() * 2 : 0.0f);
    PropertyValuesHolder pvhY = PropertyValuesHolder.ofFloat("translationY", icon.getTranslationY(), animateForward ? icon.getHeight() * 4 : 0.0f);
    PropertyValuesHolder pvhAlpha = PropertyValuesHolder.ofFloat("alpha", icon.getAlpha(), animateForward ? 0.0f : 1.0f);

    Animator animator = ObjectAnimator.ofPropertyValuesHolder(icon, pvhX, pvhY, pvhAlpha);
    animator.setDuration(FULL_ANIMATION_DURATION);
    animator.setInterpolator(new AccelerateDecelerateInterpolator());
    animator.start();

    animateForward = !animateForward;
}
 
开发者ID:zawadz88,项目名称:AnimationShowcase,代码行数:21,代码来源:ObjectAnimatorActivity.java

示例2: testAnim

import android.animation.PropertyValuesHolder; //导入方法依赖的package包/类
@NonNull
    private AnimatorSet testAnim(GiftFrameLayout giftFrameLayout) {
        PropertyValuesHolder translationY = PropertyValuesHolder.ofFloat("translationY", 0, -50);
        PropertyValuesHolder alpha = PropertyValuesHolder.ofFloat("alpha", 1.0f, 0.5f);
        ObjectAnimator animator = ObjectAnimator.ofPropertyValuesHolder(giftFrameLayout, translationY, alpha);
        animator.setStartDelay(0);
        animator.setDuration(1500);

        translationY = PropertyValuesHolder.ofFloat("translationY", -50, -100);
        alpha = PropertyValuesHolder.ofFloat("alpha", 0.5f, 0f);
        ObjectAnimator animator1 = ObjectAnimator.ofPropertyValuesHolder(giftFrameLayout, translationY, alpha);
        animator1.setStartDelay(0);
        animator1.setDuration(1500);

        // 复原
//        ObjectAnimator fadeAnimator2 = GiftAnimationUtil.createFadeAnimator(giftFrameLayout, 0, 0, 0, 0);

        AnimatorSet animatorSet = new AnimatorSet();
        animatorSet.play(animator1).after(animator);
//        animatorSet.play(fadeAnimator2).after(animator1);
        animatorSet.start();
        return animatorSet;
    }
 
开发者ID:DyncKathline,项目名称:LiveGiftLayout,代码行数:24,代码来源:CustormAnim.java

示例3: onFling

import android.animation.PropertyValuesHolder; //导入方法依赖的package包/类
@Override
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
	if (mode == DRAG) {
		if (flingDuration > 0 && !isAnimating()) {
			float factor = ((float) flingDuration / 1000f) * flingExaggeration;
			float[] values = corrector.getValues();
			float dx = (velocityX * factor) * values[Matrix.MSCALE_X];
			float dy = (velocityY * factor) * values[Matrix.MSCALE_Y];
			PropertyValuesHolder flingX = PropertyValuesHolder.ofFloat(FlingAnimatorHandler.PROPERTY_TRANSLATE_X, values[Matrix.MTRANS_X], values[Matrix.MTRANS_X] + dx);
			PropertyValuesHolder flingY = PropertyValuesHolder.ofFloat(FlingAnimatorHandler.PROPERTY_TRANSLATE_Y, values[Matrix.MTRANS_Y], values[Matrix.MTRANS_Y] + dy);
			valueAnimator = ValueAnimator.ofPropertyValuesHolder(flingX, flingY);
			valueAnimator.setDuration(flingDuration);
			valueAnimator.addUpdateListener(new FlingAnimatorHandler(corrector));
			valueAnimator.setInterpolator(new DecelerateInterpolator());
			valueAnimator.start();
			return true;
		}
	}
	return super.onFling(e1, e2, velocityX, velocityY);
}
 
开发者ID:martinwithaar,项目名称:PinchToZoom,代码行数:21,代码来源:ImageMatrixTouchHandler.java

示例4: animateMenuClosing

import android.animation.PropertyValuesHolder; //导入方法依赖的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

示例5: createNewTabOpenedAnimator

import android.animation.PropertyValuesHolder; //导入方法依赖的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

示例6: onButtonClick

import android.animation.PropertyValuesHolder; //导入方法依赖的package包/类
public void onButtonClick(View view) {
    long animationDuration = (long) (BASE_DURATION * sAnimatorScale);

    // Scale around bottom/middle to simplify squash against the window bottom
    view.setPivotX(view.getWidth() / 2);
    view.setPivotY(view.getHeight());
    
    // Animate the button down, accelerating, while also stretching in Y and squashing in X
    PropertyValuesHolder pvhTY = PropertyValuesHolder.ofFloat(View.TRANSLATION_Y,
            mContainer.getHeight() - view.getHeight());
    PropertyValuesHolder pvhSX = PropertyValuesHolder.ofFloat(View.SCALE_X, .7f);
    PropertyValuesHolder pvhSY = PropertyValuesHolder.ofFloat(View.SCALE_Y, 1.2f);
    ObjectAnimator downAnim = ObjectAnimator.ofPropertyValuesHolder(
            view, pvhTY, pvhSX, pvhSY);
    downAnim.setInterpolator(sAccelerator);
    downAnim.setDuration((long) (animationDuration * 2));

    // Stretch in X, squash in Y, then reverse
    pvhSX = PropertyValuesHolder.ofFloat(View.SCALE_X, 2);
    pvhSY = PropertyValuesHolder.ofFloat(View.SCALE_Y, .5f);
    ObjectAnimator stretchAnim =
            ObjectAnimator.ofPropertyValuesHolder(view, pvhSX, pvhSY);
    stretchAnim.setRepeatCount(1);
    stretchAnim.setRepeatMode(ValueAnimator.REVERSE);
    stretchAnim.setInterpolator(sDecelerator);
    stretchAnim.setDuration(animationDuration);
    
    // Animate back to the start
    pvhTY = PropertyValuesHolder.ofFloat(View.TRANSLATION_Y, 0);
    pvhSX = PropertyValuesHolder.ofFloat(View.SCALE_X, 1);
    pvhSY = PropertyValuesHolder.ofFloat(View.SCALE_Y, 1);
    ObjectAnimator upAnim =
            ObjectAnimator.ofPropertyValuesHolder(view, pvhTY, pvhSX, pvhSY);
    upAnim.setDuration((long) (animationDuration * 2));
    upAnim.setInterpolator(sDecelerator);

    AnimatorSet set = new AnimatorSet();
    set.playSequentially(downAnim, stretchAnim, upAnim);
    set.start();
}
 
开发者ID:sdrausty,项目名称:buildAPKsSamples,代码行数:41,代码来源:SquashAndStretch.java

示例7: fadeAndRemoveEmptyScreen

import android.animation.PropertyValuesHolder; //导入方法依赖的package包/类
private void fadeAndRemoveEmptyScreen(int delay, int duration, final Runnable onComplete,
        final boolean stripEmptyScreens) {
    // XXX: Do we need to update LM workspace screens below?
    PropertyValuesHolder alpha = PropertyValuesHolder.ofFloat("alpha", 0f);
    PropertyValuesHolder bgAlpha = PropertyValuesHolder.ofFloat("backgroundAlpha", 0f);

    final CellLayout cl = mWorkspaceScreens.get(EXTRA_EMPTY_SCREEN_ID);

    mRemoveEmptyScreenRunnable = new Runnable() {
        @Override
        public void run() {
            if (hasExtraEmptyScreen()) {
                mWorkspaceScreens.remove(EXTRA_EMPTY_SCREEN_ID);
                mScreenOrder.remove(EXTRA_EMPTY_SCREEN_ID);
                removeView(cl);
                if (stripEmptyScreens) {
                    stripEmptyScreens();
                }
                // Update the page indicator to reflect the removed page.
                showPageIndicatorAtCurrentScroll();
            }
        }
    };

    ObjectAnimator oa = ObjectAnimator.ofPropertyValuesHolder(cl, alpha, bgAlpha);
    oa.setDuration(duration);
    oa.setStartDelay(delay);
    oa.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            if (mRemoveEmptyScreenRunnable != null) {
                mRemoveEmptyScreenRunnable.run();
            }
            if (onComplete != null) {
                onComplete.run();
            }
        }
    });
    oa.start();
}
 
开发者ID:michelelacorte,项目名称:FlickLauncher,代码行数:41,代码来源:Workspace.java

示例8: buildAnimation

import android.animation.PropertyValuesHolder; //导入方法依赖的package包/类
@Override
public Animator buildAnimation(@NonNull ViewDefault viewDefault, @NonNull View viewToMorph, boolean isReversed) {
    float moveToX = 0, moveToY = 0, moveToZ = 0;
    if (target == AnimationTarget.TO) {
        if (!isReversed) {
            initialValueX = viewDefault.getX();
            initialValueY = viewDefault.getY();
            initialValueZ = viewDefault.getZ();
        }
        moveToX = isReversed ? initialValueX : translationValueX;
        moveToY = isReversed ? initialValueY : translationValueY;
        moveToZ = isReversed ? initialValueZ : translationValueZ;
        viewDefault.setX(moveToX);
        viewDefault.setY(moveToY);
        viewDefault.setZ(moveToZ);
    } else if (target == AnimationTarget.BY) {
        moveToX = viewDefault.getX() + (isReversed ? -translationValueX : translationValueX);
        moveToY = viewDefault.getY() + (isReversed ? -translationValueY : translationValueY);
        moveToZ = viewDefault.getZ() + (isReversed ? -translationValueZ : translationValueZ);
        viewDefault.setX(moveToX);
        viewDefault.setY(moveToY);
        viewDefault.setZ(moveToZ);
    }
    PropertyValuesHolder[] parameters = new PropertyValuesHolder[atLeastLollipop ? 3 : 2];
    parameters[0] = PropertyValuesHolder.ofFloat(View.X, moveToX);
    parameters[1] = PropertyValuesHolder.ofFloat(View.Y, moveToY);
    if (atLeastLollipop) {
        parameters[2] = PropertyValuesHolder.ofFloat(View.Z, moveToZ);
    }
    ObjectAnimator animator = ObjectAnimator.ofPropertyValuesHolder(viewToMorph, parameters);
    if (duration >= 0) {
        animator.setDuration(duration);
    }
    if (interpolator != null) {
        animator.setInterpolator(interpolator);
    }
    return animator;
}
 
开发者ID:rjsvieira,项目名称:morphos,代码行数:39,代码来源:TranslationAnimation.java

示例9: createBackAnimator

import android.animation.PropertyValuesHolder; //导入方法依赖的package包/类
private void createBackAnimator(
        float xStart,
        float xEnd,
        float distanceXStart,
        float distanceXEnd,
        float fractionXStart,
        float fractionXEnd) {
    mBackAnimator = new ValueAnimator();
    mXHolder = PropertyValuesHolder.ofFloat(mXHolderName, xStart, xEnd);
    mDistanceXHolder = PropertyValuesHolder.ofFloat(mDistanceXHolderName, distanceXStart, distanceXEnd);
    mFractionXHolder = PropertyValuesHolder.ofFloat(mFractionXHolderName, fractionXStart, fractionXEnd);

    mBackAnimator = ValueAnimator.ofPropertyValuesHolder(
            mXHolder,
            //        mYHolder,
            mDistanceXHolder,
            //        mDistanceYHolder
            mFractionXHolder
            //        mFractionYHolder
    );
    mBackAnimator.setDuration(mAnimationBackDuration);
    mBackAnimator.setInterpolator(mBackAnimInterpolator);
    mBackAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator valueAnimator) {
            float x = (float) valueAnimator.getAnimatedValue(mXHolderName);
            float distanceX = (float) valueAnimator.getAnimatedValue(mDistanceXHolderName);
            float fractionX = (float) valueAnimator.getAnimatedValue(mFractionXHolderName);

            handleListeners(x, distanceX, fractionX);
        }
    });
}
 
开发者ID:anmingyu11,项目名称:SwipeBackController,代码行数:34,代码来源:SwipeBackController.java

示例10: show

import android.animation.PropertyValuesHolder; //导入方法依赖的package包/类
public void show() {

        int childCount = getChildCount();
        if (childCount > 1) {

            mAngle = 0;//复位

            float x = 0.5f * mEdge;
            float y = 0.5f * mEdge;
            Animator[] anim = new Animator[childCount];

            for (int i = 0; i < childCount; i++) {

                View child = getChildAt(i);
                float pivotX = x - child.getLeft();
                float pivotY = y - child.getTop();
                child.setPivotX(pivotX);
                child.setPivotY(pivotY);
                float childX = 0.5f * child.getLeft() + child.getRight() * 0.5f;
                float childY = 0.5f * child.getTop() + 0.5f * child.getBottom();

                PropertyValuesHolder ca = PropertyValuesHolder.ofFloat("alpha", 0.5f, 1.0f);
                PropertyValuesHolder csx = PropertyValuesHolder.ofFloat("scaleX", 0, 1.0f);
                PropertyValuesHolder csy = PropertyValuesHolder.ofFloat("scaleY", 0, 1.0f);

                if (i == 0) {

                    anim[i] = ObjectAnimator.ofPropertyValuesHolder(child, ca, csx, csy);
                } else {
                    PropertyValuesHolder ctx = PropertyValuesHolder.ofFloat("translationX", -x + childX, 0);
                    PropertyValuesHolder cty = PropertyValuesHolder.ofFloat("translationY", -y + childY, 0);
                    PropertyValuesHolder cr = PropertyValuesHolder.ofFloat("rotation", 0, 360f);
                    anim[i] = ObjectAnimator.ofPropertyValuesHolder(child, ctx, cty, ca, csx, csy, cr);
                }
            }

            AnimatorSet set = new AnimatorSet();
            set.setDuration(ANIM_SHOW_DURATION);
            set.setInterpolator(new LinearInterpolator());
            set.playTogether(anim);
            set.start();
        }
    }
 
开发者ID:crazysunj,项目名称:Android-CoolMenu,代码行数:44,代码来源:CoolMenu.java

示例11: propertyValuesHolder

import android.animation.PropertyValuesHolder; //导入方法依赖的package包/类
/**
 *
 */
private void propertyValuesHolder() {
    PropertyValuesHolder holder = PropertyValuesHolder.ofFloat("translationX", 0, 300);
    PropertyValuesHolder holder1 = PropertyValuesHolder.ofFloat("scaleX", 1f, 0f, 1f);
    PropertyValuesHolder holder2 = PropertyValuesHolder.ofFloat("scaleY", 1f, 0f, 1f);
    ObjectAnimator.ofPropertyValuesHolder(content, holder, holder1, holder2).setDuration(1000).start();
}
 
开发者ID:wuhighway,项目名称:DailyStudy,代码行数:10,代码来源:AnimationDemoActivity.java

示例12: getAnimationFor

import android.animation.PropertyValuesHolder; //导入方法依赖的package包/类
@Override
public Animator getAnimationFor(AnimationBody animationBody, View view) {
    final PropertyValuesHolder alphaPVH = PropertyValuesHolder.ofFloat(View.ALPHA, 1f, 0f);
    final ValueAnimator animation =
            ObjectAnimator.ofPropertyValuesHolder(view, alphaPVH);

    return animation;
}
 
开发者ID:Appolica,项目名称:Flubber,代码行数:9,代码来源:Flash.java

示例13: init

import android.animation.PropertyValuesHolder; //导入方法依赖的package包/类
private void init() {
    PropertyValuesHolder alpha = PropertyValuesHolder.ofFloat("alpha", 1.0f, 0.4f, 1.0f);
    PropertyValuesHolder scaleX = PropertyValuesHolder.ofFloat("scaleX", 1.0f, 1.5f);
    PropertyValuesHolder scaleY = PropertyValuesHolder.ofFloat("scaleY", 1.0f, 1.5f);
    mScaleUpAnimator = ObjectAnimator.ofPropertyValuesHolder(this, alpha, scaleX, scaleY).setDuration(200);
    mScaleUpAnimator.setStartDelay(100);
    mScaleUpAnimator.setInterpolator(new AccelerateDecelerateInterpolator());
    alpha = PropertyValuesHolder.ofFloat("alpha", 1.0f, 0.4f, 1.0f);
    scaleX = PropertyValuesHolder.ofFloat("scaleX", 1.5f, 1.0f);
    scaleY = PropertyValuesHolder.ofFloat("scaleY", 1.5f, 1.0f);
    mScaleDownAnimator = ObjectAnimator.ofPropertyValuesHolder(this, alpha, scaleX, scaleY).setDuration(200);
    mScaleDownAnimator.setInterpolator(new AccelerateDecelerateInterpolator());
}
 
开发者ID:vipycm,项目名称:mao-android,代码行数:14,代码来源:CaptureButton.java

示例14: getAnimationFor

import android.animation.PropertyValuesHolder; //导入方法依赖的package包/类
@Override
public Animator getAnimationFor(AnimationBody animationBody, View view) {

    final float scale = 2 * animationBody.getForce();

    final PropertyValuesHolder alphaPVH = PropertyValuesHolder.ofFloat(View.ALPHA, 0f, 1f);
    final PropertyValuesHolder scaleXPVH = PropertyValuesHolder.ofFloat(View.SCALE_X, scale, 1f);
    final PropertyValuesHolder scaleYPVH = PropertyValuesHolder.ofFloat(View.SCALE_Y, scale, 1f);

    final ObjectAnimator animation =
            ObjectAnimator.ofPropertyValuesHolder(view, alphaPVH, scaleXPVH, scaleYPVH);

    return animation;
}
 
开发者ID:Appolica,项目名称:Flubber,代码行数:15,代码来源:ZoomIn.java

示例15: firstHideLayout

import android.animation.PropertyValuesHolder; //导入方法依赖的package包/类
public void firstHideLayout() {
    PropertyValuesHolder alpha = PropertyValuesHolder.ofFloat("alpha", 1.0f, 0f);
    ObjectAnimator animator = ObjectAnimator.ofPropertyValuesHolder(GiftFrameLayout.this, alpha);
    animator.setStartDelay(0);
    animator.setDuration(0);
    animator.start();
}
 
开发者ID:DyncKathline,项目名称:LiveGiftLayout,代码行数:8,代码来源:GiftFrameLayout.java


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