本文整理汇总了Java中com.nineoldandroids.animation.ValueAnimator.ofInt方法的典型用法代码示例。如果您正苦于以下问题:Java ValueAnimator.ofInt方法的具体用法?Java ValueAnimator.ofInt怎么用?Java ValueAnimator.ofInt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.nineoldandroids.animation.ValueAnimator
的用法示例。
在下文中一共展示了ValueAnimator.ofInt方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}
示例2: 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();
}
示例3: 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;
}
示例4: 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();
}
示例5: 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();
}
示例6: createAnimation
import com.nineoldandroids.animation.ValueAnimator; //导入方法依赖的package包/类
@Override
public List<Animator> createAnimation() {
List<Animator> animators=new ArrayList<>();
int[] durations={960, 930, 1190, 1130, 1340, 940, 1200, 820, 1190};
int[] delays= {360, 400, 680, 410, 710, -150, -120, 10, 320};
for (int i = 0; i < 9; i++) {
final int index=i;
ValueAnimator alphaAnim=ValueAnimator.ofInt(255, 168,255);
alphaAnim.setDuration(durations[i]);
alphaAnim.setRepeatCount(-1);
alphaAnim.setStartDelay(delays[i]);
alphaAnim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
alphas[index] = (int) animation.getAnimatedValue();
postInvalidate();
}
});
alphaAnim.start();
animators.add(alphaAnim);
}
return animators;
}
示例7: performAnimate
import com.nineoldandroids.animation.ValueAnimator; //导入方法依赖的package包/类
private void performAnimate(final View target, final int start, final int end) {
ValueAnimator valueAnimator = ValueAnimator.ofInt(1, 100);
valueAnimator.addUpdateListener(new AnimatorUpdateListener() {
// 持有一个IntEvaluator对象,方便下面估值的时候使用
private IntEvaluator mEvaluator = new IntEvaluator();
@Override
public void onAnimationUpdate(ValueAnimator animator) {
// 获得当前动画的进度值,整型,1-100之间
int currentValue = (Integer) animator.getAnimatedValue();
Log.d(TAG, "current value: " + currentValue);
// 获得当前进度占整个动画过程的比例,浮点型,0-1之间
float fraction = animator.getAnimatedFraction();
// 直接调用整型估值器通过比例计算出宽度,然后再设给Button
target.getLayoutParams().width = mEvaluator.evaluate(fraction, start, end);
target.requestLayout();
}
});
valueAnimator.setDuration(5000).start();
}
示例8: getWidthAnimator
import com.nineoldandroids.animation.ValueAnimator; //导入方法依赖的package包/类
private Animator getWidthAnimator(final int from, final int to) {
final ValueAnimator anim = ValueAnimator.ofInt(from, to);
anim.addUpdateListener(new AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
final int val = (Integer)animation.getAnimatedValue();
final ViewGroup.LayoutParams layoutParams = getLayoutParams();
layoutParams.width = val;
setLayoutParams(layoutParams);
}
});
anim.setInterpolator(new FastOutSlowInInterpolator());
anim.setDuration(TRANSITION_MS);
return anim;
}
示例9: getView
import com.nineoldandroids.animation.ValueAnimator; //导入方法依赖的package包/类
@Override
@NonNull
public View getView(final int position, @Nullable final View convertView, @NonNull final ViewGroup parent) {
final View view = super.getView(position, convertView, parent);
if (mInsertQueue.getActiveIndexes().contains(position)) {
int widthMeasureSpec = View.MeasureSpec.makeMeasureSpec(ViewGroup.LayoutParams.MATCH_PARENT, View.MeasureSpec.AT_MOST);
int heightMeasureSpec = View.MeasureSpec.makeMeasureSpec(ViewGroup.LayoutParams.WRAP_CONTENT, View.MeasureSpec.UNSPECIFIED);
view.measure(widthMeasureSpec, heightMeasureSpec);
int originalHeight = view.getMeasuredHeight();
ValueAnimator heightAnimator = ValueAnimator.ofInt(1, originalHeight);
heightAnimator.addUpdateListener(new HeightUpdater(view));
Animator[] customAnimators = getAdditionalAnimators(view, parent);
Animator[] animators = new Animator[customAnimators.length + 1];
animators[0] = heightAnimator;
System.arraycopy(customAnimators, 0, animators, 1, customAnimators.length);
AnimatorSet animatorSet = new AnimatorSet();
animatorSet.playTogether(animators);
ViewHelper.setAlpha(view, 0);
ObjectAnimator alphaAnimator = ObjectAnimator.ofFloat(view, ALPHA, 0, 1);
AnimatorSet allAnimatorsSet = new AnimatorSet();
allAnimatorsSet.playSequentially(animatorSet, alphaAnimator);
allAnimatorsSet.setDuration(mInsertionAnimationDurationMs);
allAnimatorsSet.addListener(new ExpandAnimationListener(position));
allAnimatorsSet.start();
}
return view;
}
示例10: 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 valueAnimator) {
int value = (Integer) valueAnimator.getAnimatedValue();
ViewGroup.LayoutParams layoutParams = view.getLayoutParams();
layoutParams.height = value;
view.setLayoutParams(layoutParams);
}
});
return animator;
}
示例11: startChangeWholeHeaderViewPaddingTop
import com.nineoldandroids.animation.ValueAnimator; //导入方法依赖的package包/类
public void startChangeWholeHeaderViewPaddingTop(int distance) {
ValueAnimator animator = ValueAnimator.ofInt(mWholeHeaderView.getPaddingTop(), mWholeHeaderView.getPaddingTop() - distance);
animator.setDuration(mRefreshViewHolder.getTopAnimDuration());
animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
int paddingTop = (int) animation.getAnimatedValue();
mWholeHeaderView.setPadding(0, paddingTop, 0, 0);
}
});
animator.start();
}
示例12: hiddenRefreshHeaderView
import com.nineoldandroids.animation.ValueAnimator; //导入方法依赖的package包/类
/**
* 隐藏下拉刷新控件,带动画
*/
private void hiddenRefreshHeaderView() {
ValueAnimator animator = ValueAnimator.ofInt(mWholeHeaderView.getPaddingTop(), mMinWholeHeaderViewPaddingTop);
animator.setDuration(mRefreshViewHolder.getTopAnimDuration());
animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
int paddingTop = (int) animation.getAnimatedValue();
mWholeHeaderView.setPadding(0, paddingTop, 0, 0);
}
});
animator.start();
}
示例13: changeRefreshHeaderViewToZero
import com.nineoldandroids.animation.ValueAnimator; //导入方法依赖的package包/类
/**
* 设置下拉刷新控件的paddingTop到0,带动画
*/
private void changeRefreshHeaderViewToZero() {
ValueAnimator animator = ValueAnimator.ofInt(mWholeHeaderView.getPaddingTop(), 0);
animator.setDuration(mRefreshViewHolder.getTopAnimDuration());
animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
int paddingTop = (int) animation.getAnimatedValue();
mWholeHeaderView.setPadding(0, paddingTop, 0, 0);
}
});
animator.start();
}
示例14: setProgress
import com.nineoldandroids.animation.ValueAnimator; //导入方法依赖的package包/类
/**
* 设置进度,此为线程安全控件,由于考虑多线的问题,需要同步 刷新界面调用postInvalidate()能在非UI线程刷新
*
* @param progress
*/
public synchronized void setProgress(int progress) {
if (this.progress == progress) {
return;
}
// hasShowing = true;
if (progress < 0) {
// throw new IllegalArgumentException("progress not less than 0");
return;
}
if (progress > max) {
progress = max;
}
ValueAnimator va = ValueAnimator.ofInt(this.progress, progress);
va.setDuration(1000);
va.setInterpolator(new AccelerateInterpolator());
va.start();
va.addUpdateListener(new AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator arg0) {
int value = (Integer) arg0.getAnimatedValue();
if (value <= max) {
RoundProgressBar.this.progress = value;
invalidate();
}
}
});
}
示例15: reduce
import com.nineoldandroids.animation.ValueAnimator; //导入方法依赖的package包/类
public void reduce() {
if (expanded) {
ValueAnimator expand = ValueAnimator.ofInt(card.getHeight(), cardCollapsedHeight);
expand.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
Integer value = (Integer) animation.getAnimatedValue();
card.getLayoutParams().height = value.intValue();
card.requestLayout();
}
});
AnimatorSet animatorSet = new AnimatorSet();
animatorSet.setDuration(ANIMATION_DURATION);
animatorSet.playTogether(
ObjectAnimator.ofFloat(label, "alpha", 1),
ObjectAnimator.ofFloat(label, "scaleX", 1),
ObjectAnimator.ofFloat(label, "scaleY", 1),
ObjectAnimator.ofFloat(label, "translationY", 0),
ObjectAnimator.ofFloat(image, "alpha", 0),
ObjectAnimator.ofFloat(image, "scaleX", 0.4f),
ObjectAnimator.ofFloat(image, "scaleY", 0.4f),
ObjectAnimator.ofFloat(editText, "alpha", 0),
expand
);
animatorSet.start();
if (OPEN_KEYBOARD_ON_FOCUS)
((InputMethodManager) getContext().getSystemService(Context.INPUT_METHOD_SERVICE)).toggleSoftInput(InputMethodManager.HIDE_IMPLICIT_ONLY, 0);
editText.clearFocus();
expanded = false;
}
}