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


Java ValueAnimator類代碼示例

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


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

示例1: initAnimations

import com.nineoldandroids.animation.ValueAnimator; //導入依賴的package包/類
private void initAnimations() {
    searchAnimation = ValueAnimator.ofFloat(0f, 1f);
    searchAnimation.setDuration(50000);
    searchAnimation.setRepeatCount(ValueAnimator.INFINITE);
    searchAnimation.setRepeatMode(ValueAnimator.RESTART);
    searchAnimation.setInterpolator(new LinearInterpolator());
    searchAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator valueAnimator) {
            float angle = (valueAnimator.getAnimatedFraction() * 360);
            ViewHelper.setTranslationX(ivSearch, (float) Math.sin(angle) * radius);
            ViewHelper.setTranslationY(ivSearch, (float) Math.cos(angle) * radius);
        }
    });


    scanAnimation = new TranslateAnimation(TranslateAnimation.RELATIVE_TO_PARENT, 0f, TranslateAnimation.RELATIVE_TO_PARENT, 0f, TranslateAnimation.RELATIVE_TO_PARENT, 0f, TranslateAnimation.RELATIVE_TO_PARENT, 0.61f);
    scanAnimation.setDuration(2000);
    scanAnimation.setRepeatCount(TranslateAnimation.INFINITE);
    scanAnimation.setRepeatMode(TranslateAnimation.RESTART);
}
 
開發者ID:piyell,項目名稱:NeteaseCloudMusic,代碼行數:22,代碼來源:ScanMusicActivity.java

示例2: startAnimation

import com.nineoldandroids.animation.ValueAnimator; //導入依賴的package包/類
/**
 * Starts the underlying Animator for a set of properties. We use a single animator that
 * simply runs from 0 to 1, and then use that fractional value to set each property
 * value accordingly.
 */
private void startAnimation() {
    ValueAnimator animator = ValueAnimator.ofFloat(1.0f);
    ArrayList<NameValuesHolder> nameValueList =
            (ArrayList<NameValuesHolder>) mPendingAnimations.clone();
    mPendingAnimations.clear();
    int propertyMask = 0;
    int propertyCount = nameValueList.size();
    for (int i = 0; i < propertyCount; ++i) {
        NameValuesHolder nameValuesHolder = nameValueList.get(i);
        propertyMask |= nameValuesHolder.mNameConstant;
    }
    mAnimatorMap.put(animator, new PropertyBundle(propertyMask, nameValueList));
    animator.addUpdateListener(mAnimatorEventListener);
    animator.addListener(mAnimatorEventListener);
    if (mStartDelaySet) {
        animator.setStartDelay(mStartDelay);
    }
    if (mDurationSet) {
        animator.setDuration(mDuration);
    }
    if (mInterpolatorSet) {
        animator.setInterpolator(mInterpolator);
    }
    animator.start();
}
 
開發者ID:junchenChow,項目名稱:exciting-app,代碼行數:31,代碼來源:ViewPropertyAnimatorHC.java

示例3: custom

import com.nineoldandroids.animation.ValueAnimator; //導入依賴的package包/類
/**
 * Custom animation builder.
 *
 * @param update the update
 * @param values the values
 * @return the animation builder
 */
public AnimationBuilder custom(final AnimationListener.Update update, float... values) {
    for (final View view : views) {
        ValueAnimator valueAnimator = ValueAnimator.ofFloat(getValues(values));
        if (update != null)
            valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
                @Override
                public void onAnimationUpdate(ValueAnimator animation) {
                    //noinspection unchecked
                    update.update(view, (Float) animation.getAnimatedValue());
                }
            });
        add(valueAnimator);
    }
    return this;
}
 
開發者ID:junchenChow,項目名稱:exciting-app,代碼行數:23,代碼來源:AnimationBuilder.java

示例4: onTouchEvent

import com.nineoldandroids.animation.ValueAnimator; //導入依賴的package包/類
@Override
public boolean onTouchEvent(MotionEvent ev) {
    if (ev.getAction() == MotionEvent.ACTION_UP) {
        // 恢複高度
        final ValueAnimator animator = ValueAnimator.ofInt(parallaxImageView.getHeight(), originalHeight);
        animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
            @Override
            public void onAnimationUpdate(ValueAnimator valueAnimator) {
                Integer animateValue = (Integer) animator.getAnimatedValue();
                // 給 ImageView 設置值
                parallaxImageView.getLayoutParams().height = animateValue;
                parallaxImageView.requestLayout();
            }
        });
        animator.setInterpolator(new OvershootInterpolator()); // 彈性差值器
        animator.setDuration(450);
        animator.start();
    }
    return super.onTouchEvent(ev);
}
 
開發者ID:sleticalboy,項目名稱:CustomWeight,代碼行數:21,代碼來源:ParallaxListView.java

示例5: startAnimation

import com.nineoldandroids.animation.ValueAnimator; //導入依賴的package包/類
private void startAnimation() {
    ValueAnimator animator = ValueAnimator.ofFloat(new float[]{1.0f});
    ArrayList<NameValuesHolder> nameValueList = (ArrayList) this.mPendingAnimations.clone();
    this.mPendingAnimations.clear();
    int propertyMask = 0;
    for (int i = 0; i < nameValueList.size(); i++) {
        propertyMask |= ((NameValuesHolder) nameValueList.get(i)).mNameConstant;
    }
    this.mAnimatorMap.put(animator, new PropertyBundle(propertyMask, nameValueList));
    animator.addUpdateListener(this.mAnimatorEventListener);
    animator.addListener(this.mAnimatorEventListener);
    if (this.mStartDelaySet) {
        animator.setStartDelay(this.mStartDelay);
    }
    if (this.mDurationSet) {
        animator.setDuration(this.mDuration);
    }
    if (this.mInterpolatorSet) {
        animator.setInterpolator(this.mInterpolator);
    }
    animator.start();
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:23,代碼來源:ViewPropertyAnimatorHC.java

示例6: hideBubble

import com.nineoldandroids.animation.ValueAnimator; //導入依賴的package包/類
private void hideBubble() {

        if (mBubbleAnimator == null) {
            mBubbleAnimator = ValueAnimator.ofFloat(1.0F, 0.0F);
            mBubbleAnimator.addUpdateListener(mBubbleAnimatorListener);
            mBubbleAnimator.addListener(new AnimatorListenerAdapter() {
                @Override
                public void onAnimationEnd(Animator animation) {
                    mBubbleVisible = false;
                    invalidate();
                }
            });
        } else {
            mBubbleAnimator.cancel();
        }


        mBubbleAnimator.start();
    }
 
開發者ID:andryr,項目名稱:Harmony-Music-Player,代碼行數:20,代碼來源:FastScroller.java

示例7: hideScroller

import com.nineoldandroids.animation.ValueAnimator; //導入依賴的package包/類
private void hideScroller() {

        if (mScrollerAnimator == null) {
            mScrollerAnimator = ValueAnimator.ofFloat(1.0F, 0.0F);
            mScrollerAnimator.addUpdateListener(mHandleAnimatorListener);
            mScrollerAnimator.addListener(new AnimatorListenerAdapter() {
                @Override
                public void onAnimationEnd(Animator animation) {
                    mScrollerVisible = false;
                    invalidate();
                }
            });
        } else {
            mScrollerAnimator.cancel();
        }


        mScrollerAnimator.start();


    }
 
開發者ID:andryr,項目名稱:Harmony-Music-Player,代碼行數:22,代碼來源:FastScroller.java

示例8: dropTempWindow

import com.nineoldandroids.animation.ValueAnimator; //導入依賴的package包/類
private void dropTempWindow() {
    mInputBox.setVisibility(View.INVISIBLE);
    ValueAnimator va = ValueAnimator.ofInt(mEnterLayoutAnimSupportContainer.softkeyboardOpenY, mEnterLayoutAnimSupportContainer.openY);
    va.setDuration(300);
    va.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            int y = (int) animation.getAnimatedValue();
            int b = (y - mEnterLayoutAnimSupportContainer.softkeyboardOpenY) * panelHeight / (mEnterLayoutAnimSupportContainer.openY - mEnterLayoutAnimSupportContainer.softkeyboardOpenY) - panelHeight;
            moveTempWindow(y);
            updateEnterLayoutBottom(b);
            if (y == mEnterLayoutAnimSupportContainer.openY) {
                removeTempWindow();
                mInputBox.setVisibility(View.VISIBLE);
            }
        }
    });
    va.start();

}
 
開發者ID:huang303513,項目名稱:Coding-Android,代碼行數:21,代碼來源:EnterEmojiLayout.java

示例9: createHeightAnimator

import com.nineoldandroids.animation.ValueAnimator; //導入依賴的package包/類
public static ValueAnimator createHeightAnimator(final View view, final int start, final int end) {
    ValueAnimator animator = ValueAnimator.ofInt(start, end);
    animator.addUpdateListener(
            new ValueAnimator.AnimatorUpdateListener() {

                @Override
                public void onAnimationUpdate(final ValueAnimator animation) {
                    int value = (Integer) animation.getAnimatedValue();

                    LayoutParams layoutParams = view.getLayoutParams();
                    layoutParams.height = value;
                    view.setLayoutParams(layoutParams);
                }
            }
    );
    return animator;
}
 
開發者ID:sathishmscict,項目名稱:ListViewAnimations,代碼行數:18,代碼來源:ExpandableListItemAdapter.java

示例10: animateToolbar

import com.nineoldandroids.animation.ValueAnimator; //導入依賴的package包/類
private void animateToolbar(final float toY) {
    float layoutTranslationY = ViewHelper.getTranslationY(mInterceptionLayout);
    if (layoutTranslationY != toY) {
        ValueAnimator animator = ValueAnimator.ofFloat(ViewHelper.getTranslationY(mInterceptionLayout), toY).setDuration(200);
        animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
            @Override
            public void onAnimationUpdate(ValueAnimator animation) {
                float translationY = (float) animation.getAnimatedValue();
                ViewHelper.setTranslationY(mInterceptionLayout, translationY);
                if (translationY < 0) {
                    FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) mInterceptionLayout.getLayoutParams();
                    lp.height = (int) (-translationY + getScreenHeight());
                    mInterceptionLayout.requestLayout();
                }
            }
        });
        animator.start();
    }
}
 
開發者ID:LeMinhAn,項目名稱:AndroidObservableScrollView-master,代碼行數:20,代碼來源:ViewPagerTab2Activity.java

示例11: moveToolbar

import com.nineoldandroids.animation.ValueAnimator; //導入依賴的package包/類
private void moveToolbar(float toTranslationY) {
    if (ViewHelper.getTranslationY(mToolbar) == toTranslationY) {
        return;
    }
    ValueAnimator animator = ValueAnimator.ofFloat(ViewHelper.getTranslationY(mToolbar), toTranslationY).setDuration(200);
    animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            float translationY = (float) animation.getAnimatedValue();
            ViewHelper.setTranslationY(mToolbar, translationY);
            ViewHelper.setTranslationY((View) mScrollable, translationY);
            FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) ((View) mScrollable).getLayoutParams();
            lp.height = (int) -translationY + getScreenHeight() - lp.topMargin;
            ((View) mScrollable).requestLayout();
        }
    });
    animator.start();
}
 
開發者ID:LeMinhAn,項目名稱:AndroidObservableScrollView-master,代碼行數:19,代碼來源:ToolbarControlBaseActivity.java

示例12: animateToolbar

import com.nineoldandroids.animation.ValueAnimator; //導入依賴的package包/類
private void animateToolbar(final float toY) {
    float layoutTranslationY = ViewHelper.getTranslationY(mInterceptionLayout);
    if (layoutTranslationY != toY) {
        ValueAnimator animator = ValueAnimator.ofFloat(ViewHelper.getTranslationY(mInterceptionLayout), toY).setDuration(200);
        animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
            @Override
            public void onAnimationUpdate(ValueAnimator animation) {
                float translationY = (float) animation.getAnimatedValue();
                View toolbarView = getActivity().findViewById(R.id.toolbar);
                ViewHelper.setTranslationY(mInterceptionLayout, translationY);
                ViewHelper.setTranslationY(toolbarView, translationY);
                if (translationY < 0) {
                    FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) mInterceptionLayout.getLayoutParams();
                    lp.height = (int) (-translationY + getScreenHeight());
                    mInterceptionLayout.requestLayout();
                }
            }
        });
        animator.start();
    }
}
 
開發者ID:LeMinhAn,項目名稱:AndroidObservableScrollView-master,代碼行數:22,代碼來源:ViewPagerTabFragmentParentFragment.java

示例13: animateCirlce

import com.nineoldandroids.animation.ValueAnimator; //導入依賴的package包/類
/**
 * Internal void to start the circles animation.
 * <p>
 * when this void is called the circles radius would be updated by a
 * {@link ValueAnimator} and then it will call the {@link View}'s
 * invalidate() void witch calls the onDraw void each time so a bigger
 * circle would be drawn each time till the cirlce's fill the whole screen.
 * </p>
 */
private void animateCirlce() {
	if (circles_fill_type == CIRLCES_FILL_HEIGHT_TYPE) {
		circle_max_radius = screen_height + (screen_height / 4);
	} else {
		circle_max_radius = screen_width + (screen_width / 4);
	}
	ValueAnimator va = ValueAnimator.ofInt(0, circle_max_radius / 3);
	va.setDuration(1000);
	va.addListener(this);
	va.setInterpolator(new AccelerateInterpolator());
	va.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
		public void onAnimationUpdate(ValueAnimator animation) {
			int value = (int) animation.getAnimatedValue();
			circle_radius = value * 3;
			invalidate();
		}
	});
	va.start();
}
 
開發者ID:Mahfa,項目名稱:AndroidColorPop,代碼行數:29,代碼來源:PopBackgroundView.java

示例14: animateRect

import com.nineoldandroids.animation.ValueAnimator; //導入依賴的package包/類
/**
 * Internal void to start the rectangle animation.
 * <p>
 * when this void is called the space at the top of the rectangle would be
 * updated by a {@link ValueAnimator} and then it will call the {@link View}
 * 's invalidate() void witch calls the onDraw void each time so a bigger
 * rectangle would be drawn each time till the it the rectangles height is
 * enough
 * </p>
 */
private void animateRect() {
	ValueAnimator va = ValueAnimator.ofInt(rect_space_top / 2,
			screen_height / 2);
	va.setDuration(500);
	va.addListener(this);
	va.setInterpolator(new DecelerateInterpolator());
	va.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
		public void onAnimationUpdate(ValueAnimator animation) {
			int value = ((int) animation.getAnimatedValue()) * 2;
			int rect_top = -((value - rect_space_top) - screen_height);
			rect.top = rect_top;
			invalidate();
		}
	});
	va.start();
}
 
開發者ID:Mahfa,項目名稱:AndroidColorPop,代碼行數:27,代碼來源:PopBackgroundView.java

示例15: performRemovalIfNecessary

import com.nineoldandroids.animation.ValueAnimator; //導入依賴的package包/類
private void performRemovalIfNecessary() {
    if (mCurrentRemovedId == -1) {
        return;
    }

    ContextualUndoView currentRemovedView = getCurrentRemovedView(mCurrentRemovedView, mCurrentRemovedId);
    if (currentRemovedView != null) {
        ValueAnimator animator = ValueAnimator.ofInt(currentRemovedView.getHeight(), 1).setDuration(ANIMATION_DURATION);

        RemoveViewAnimatorListenerAdapter listener = new RemoveViewAnimatorListenerAdapter(currentRemovedView, mCurrentRemovedId);
        RemoveViewAnimatorUpdateListener updateListener = new RemoveViewAnimatorUpdateListener(listener);

        animator.addListener(listener);
        animator.addUpdateListener(updateListener);
        animator.start();
    } else {
        // The hard way.
        deleteItemGivenId(mCurrentRemovedId);
    }
    clearCurrentRemovedView();
}
 
開發者ID:xulailing,項目名稱:android-open-project-demo-master,代碼行數:22,代碼來源:ContextualUndoAdapter.java


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