本文整理匯總了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;
}
}