本文整理汇总了Java中com.nineoldandroids.animation.ValueAnimator.setInterpolator方法的典型用法代码示例。如果您正苦于以下问题:Java ValueAnimator.setInterpolator方法的具体用法?Java ValueAnimator.setInterpolator怎么用?Java ValueAnimator.setInterpolator使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.nineoldandroids.animation.ValueAnimator
的用法示例。
在下文中一共展示了ValueAnimator.setInterpolator方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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();
}
示例2: 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);
}
示例3: 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();
}
示例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: expandView
import com.nineoldandroids.animation.ValueAnimator; //导入方法依赖的package包/类
public void expandView(final View view) {
ValueAnimator animator = ValueAnimator.ofFloat(0, 1);
animator.setInterpolator(new DecelerateInterpolator());
animator.setDuration(200);
animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
ViewHelper.setRotation(view,180 * (float) (animation.getAnimatedValue()));
view.postInvalidate();
}
});
animator.start();
}
示例7: collapseView
import com.nineoldandroids.animation.ValueAnimator; //导入方法依赖的package包/类
public void collapseView(final View view) {
ValueAnimator animator = ValueAnimator.ofFloat(1, 0);
animator.setInterpolator(new DecelerateInterpolator());
animator.setDuration(200);
animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
ViewHelper.setRotation(view,180 * (float) (animation.getAnimatedValue()));
view.postInvalidate();
}
});
animator.start();
}
示例8: moveTo
import com.nineoldandroids.animation.ValueAnimator; //导入方法依赖的package包/类
public void moveTo(final float i, int duration) {
int topMargin = getHeaderTopMargin();
ValueAnimator animator = ValueAnimator.ofFloat(topMargin, i);
animator.setDuration(duration);
animator.setInterpolator(new DecelerateInterpolator());
mPullStateE = PullStateE.PULL_STATE_NONE;
animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public void onAnimationUpdate(ValueAnimator valueAnimator) {
float temp = (Float) valueAnimator.getAnimatedValue();
if (temp == i) {
mPullStateE = PullStateE.PULL_STATE_NONE;
}
setHeaderTopMargin((int) temp);
}
});
animator.start();
}
示例9: 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;
}
示例10: restoreStepperContent
import com.nineoldandroids.animation.ValueAnimator; //导入方法依赖的package包/类
/**
* 中间滑条恢复原位置
*/
private void restoreStepperContent() {
if (animationing) return;
animationing = true;
ValueAnimator restoreTranslateAnimation = ValueAnimator.ofFloat(tvStepperContent.getLeft(), (int) startStepperContentLeft);
restoreTranslateAnimation.setDuration(ANIMATIONDURATION);
restoreTranslateAnimation.addListener(this);
restoreTranslateAnimation.addUpdateListener(this);
restoreTranslateAnimation.setInterpolator(new AccelerateInterpolator());
restoreTranslateAnimation.start();
}
示例11: 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();
}
}
});
}
示例12: a
import com.nineoldandroids.animation.ValueAnimator; //导入方法依赖的package包/类
private void a()
{
ValueAnimator valueanimator = ValueAnimator.ofFloat(new float[] {
1.0F
});
ArrayList arraylist = (ArrayList)a.clone();
a.clear();
int i1 = arraylist.size();
int j1 = 0;
int k1 = 0;
do
{
if (j1 >= i1)
{
y.put(valueanimator, new m(k1, arraylist));
valueanimator.addUpdateListener(k);
valueanimator.addListener(k);
if (g)
{
valueanimator.setStartDelay(f);
}
if (e)
{
valueanimator.setDuration(d);
}
if (i)
{
valueanimator.setInterpolator(h);
}
valueanimator.start();
return;
}
k1 |= ((l)arraylist.get(j1)).a;
j1++;
} while (true);
}
示例13: a
import com.nineoldandroids.animation.ValueAnimator; //导入方法依赖的package包/类
private void a()
{
ValueAnimator valueanimator = ValueAnimator.ofFloat(new float[] {
1.0F
});
ArrayList arraylist = (ArrayList)a.clone();
a.clear();
int i1 = arraylist.size();
int j1 = 0;
int k1 = 0;
do
{
if (j1 >= i1)
{
x.put(valueanimator, new f(k1, arraylist));
valueanimator.addUpdateListener(j);
valueanimator.addListener(j);
if (f)
{
valueanimator.setStartDelay(e);
}
if (d)
{
valueanimator.setDuration(c);
}
if (h)
{
valueanimator.setInterpolator(g);
}
valueanimator.start();
return;
}
k1 |= ((e)arraylist.get(j1)).a;
j1++;
} while (true);
}
示例14: onTouchEvent
import com.nineoldandroids.animation.ValueAnimator; //导入方法依赖的package包/类
@Override
public boolean onTouchEvent(MotionEvent event) {
if (event.getAction() != MotionEvent.ACTION_DOWN &&
event.getAction() != MotionEvent.ACTION_MOVE) {
return false;
}
ShapeHolder newBall = addBall(event.getX(), event.getY());
// Bouncing animation with squash and stretch
float startY = newBall.getY();
float endY = getHeight() - 50f;
float h = (float)getHeight();
float eventY = event.getY();
int duration = (int)(500 * ((h - eventY)/h));
ValueAnimator bounceAnim = ObjectAnimator.ofFloat(newBall, "y", startY, endY);
bounceAnim.setDuration(duration);
bounceAnim.setInterpolator(new AccelerateInterpolator());
ValueAnimator squashAnim1 = ObjectAnimator.ofFloat(newBall, "x", newBall.getX(),
newBall.getX() - 25f);
squashAnim1.setDuration(duration/4);
squashAnim1.setRepeatCount(1);
squashAnim1.setRepeatMode(ValueAnimator.REVERSE);
squashAnim1.setInterpolator(new DecelerateInterpolator());
ValueAnimator squashAnim2 = ObjectAnimator.ofFloat(newBall, "width", newBall.getWidth(),
newBall.getWidth() + 50);
squashAnim2.setDuration(duration/4);
squashAnim2.setRepeatCount(1);
squashAnim2.setRepeatMode(ValueAnimator.REVERSE);
squashAnim2.setInterpolator(new DecelerateInterpolator());
ValueAnimator stretchAnim1 = ObjectAnimator.ofFloat(newBall, "y", endY,
endY + 25f);
stretchAnim1.setDuration(duration/4);
stretchAnim1.setRepeatCount(1);
stretchAnim1.setInterpolator(new DecelerateInterpolator());
stretchAnim1.setRepeatMode(ValueAnimator.REVERSE);
ValueAnimator stretchAnim2 = ObjectAnimator.ofFloat(newBall, "height",
newBall.getHeight(), newBall.getHeight() - 25);
stretchAnim2.setDuration(duration/4);
stretchAnim2.setRepeatCount(1);
stretchAnim2.setInterpolator(new DecelerateInterpolator());
stretchAnim2.setRepeatMode(ValueAnimator.REVERSE);
ValueAnimator bounceBackAnim = ObjectAnimator.ofFloat(newBall, "y", endY,
startY);
bounceBackAnim.setDuration(duration);
bounceBackAnim.setInterpolator(new DecelerateInterpolator());
// Sequence the down/squash&stretch/up animations
AnimatorSet bouncer = new AnimatorSet();
bouncer.play(bounceAnim).before(squashAnim1);
bouncer.play(squashAnim1).with(squashAnim2);
bouncer.play(squashAnim1).with(stretchAnim1);
bouncer.play(squashAnim1).with(stretchAnim2);
bouncer.play(bounceBackAnim).after(stretchAnim2);
// Fading animation - remove the ball when the animation is done
ValueAnimator fadeAnim = ObjectAnimator.ofFloat(newBall, "alpha", 1f, 0f);
fadeAnim.setDuration(250);
fadeAnim.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
balls.remove(((ObjectAnimator)animation).getTarget());
}
});
// Sequence the two animations to play one after the other
AnimatorSet animatorSet = new AnimatorSet();
animatorSet.play(bouncer).before(fadeAnim);
// Start the animation
animatorSet.start();
return true;
}
示例15: queue
import com.nineoldandroids.animation.ValueAnimator; //导入方法依赖的package包/类
public void queue(Attributes attrs) {
final ValueAnimator animator = ObjectAnimator.ofFloat(mView, mPropertyName, attrs.value);
animator.setDuration(attrs.durationMs);
animator.setInterpolator(new AccelerateInterpolator());
animatorChain.add(animator);
}