本文整理汇总了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);
}
示例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();
}
示例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;
}
示例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);
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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;
}
示例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();
}
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}