Animation classname changes
Change-Id: I0b3b5f1563ab0ac301684880957ed55ebfc54da5
This commit is contained in:
@@ -14,15 +14,15 @@
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
<sequencer>
|
||||
<property xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<set>
|
||||
<objectAnimator xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:duration="1000"
|
||||
android:valueTo="200"
|
||||
android:valueType="floatType"
|
||||
android:propertyName="x"
|
||||
android:repeatCount="1"
|
||||
android:repeatMode="reverse"/>
|
||||
<property xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<objectAnimator xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:duration="1000"
|
||||
android:valueFrom="0"
|
||||
android:valueTo="400"
|
||||
@@ -30,4 +30,4 @@
|
||||
android:propertyName="y"
|
||||
android:repeatCount="1"
|
||||
android:repeatMode="reverse"/>
|
||||
</sequencer>
|
||||
</set>
|
||||
@@ -30,9 +30,7 @@ import android.graphics.RadialGradient;
|
||||
import android.graphics.Shader;
|
||||
import android.graphics.drawable.ShapeDrawable;
|
||||
import android.graphics.drawable.shapes.OvalShape;
|
||||
import android.graphics.drawable.shapes.RectShape;
|
||||
import android.os.Bundle;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.animation.AccelerateInterpolator;
|
||||
import android.view.animation.DecelerateInterpolator;
|
||||
@@ -60,10 +58,10 @@ public class AnimationCloning extends Activity {
|
||||
});
|
||||
}
|
||||
|
||||
public class MyAnimationView extends View implements Animator.AnimatorUpdateListener {
|
||||
public class MyAnimationView extends View implements ValueAnimator.AnimatorUpdateListener {
|
||||
|
||||
public final ArrayList<ShapeHolder> balls = new ArrayList<ShapeHolder>();
|
||||
Sequencer animation = null;
|
||||
AnimatorSet animation = null;
|
||||
private float mDensity;
|
||||
|
||||
public MyAnimationView(Context context) {
|
||||
@@ -81,27 +79,27 @@ public class AnimationCloning extends Activity {
|
||||
|
||||
private void createAnimation() {
|
||||
if (animation == null) {
|
||||
PropertyAnimator anim1 = new PropertyAnimator(500, balls.get(0), "y",
|
||||
ObjectAnimator anim1 = new ObjectAnimator(500, balls.get(0), "y",
|
||||
0f, getHeight() - balls.get(0).getHeight());
|
||||
PropertyAnimator anim2 = anim1.clone();
|
||||
ObjectAnimator anim2 = anim1.clone();
|
||||
anim2.setTarget(balls.get(1));
|
||||
anim1.addUpdateListener(this);
|
||||
|
||||
ShapeHolder ball2 = balls.get(2);
|
||||
PropertyAnimator animDown = new PropertyAnimator(500, ball2, "y",
|
||||
ObjectAnimator animDown = new ObjectAnimator(500, ball2, "y",
|
||||
0f, getHeight() - ball2.getHeight());
|
||||
animDown.setInterpolator(new AccelerateInterpolator());
|
||||
PropertyAnimator animUp = new PropertyAnimator(500, ball2, "y",
|
||||
ObjectAnimator animUp = new ObjectAnimator(500, ball2, "y",
|
||||
getHeight() - ball2.getHeight(), 0f);
|
||||
animDown.setInterpolator(new DecelerateInterpolator());
|
||||
Sequencer s1 = new Sequencer();
|
||||
AnimatorSet s1 = new AnimatorSet();
|
||||
s1.playSequentially(animDown, animUp);
|
||||
animDown.addUpdateListener(this);
|
||||
animUp.addUpdateListener(this);
|
||||
Sequencer s2 = (Sequencer) s1.clone();
|
||||
AnimatorSet s2 = (AnimatorSet) s1.clone();
|
||||
s2.setTarget(balls.get(3));
|
||||
|
||||
animation = new Sequencer();
|
||||
animation = new AnimatorSet();
|
||||
animation.playTogether(anim1, anim2, s1);
|
||||
animation.playSequentially(s1, s2);
|
||||
}
|
||||
@@ -144,7 +142,7 @@ public class AnimationCloning extends Activity {
|
||||
animation.start();
|
||||
}
|
||||
|
||||
public void onAnimationUpdate(Animator animation) {
|
||||
public void onAnimationUpdate(ValueAnimator animation) {
|
||||
invalidate();
|
||||
}
|
||||
|
||||
|
||||
@@ -18,15 +18,15 @@ package com.example.android.apis.animation;
|
||||
|
||||
// Need the following import to get access to the app resources, since this
|
||||
// class is in a sub-package.
|
||||
import android.animation.AnimatableInflater;
|
||||
import android.animation.AnimatorInflater;
|
||||
import android.animation.AnimatorSet;
|
||||
import android.animation.ObjectAnimator;
|
||||
import com.example.android.apis.R;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import android.animation.Animatable;
|
||||
import android.animation.Animator;
|
||||
import android.animation.PropertyAnimator;
|
||||
import android.animation.Sequencer;
|
||||
import android.animation.ValueAnimator;
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.graphics.Canvas;
|
||||
@@ -41,7 +41,7 @@ import android.widget.Button;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
/**
|
||||
* This application demonstrates loading Animatable objects from XML resources.
|
||||
* This application demonstrates loading Animator objects from XML resources.
|
||||
*/
|
||||
public class AnimationLoading extends Activity {
|
||||
|
||||
@@ -67,12 +67,12 @@ public class AnimationLoading extends Activity {
|
||||
|
||||
}
|
||||
|
||||
public class MyAnimationView extends View implements Animator.AnimatorUpdateListener {
|
||||
public class MyAnimationView extends View implements ValueAnimator.AnimatorUpdateListener {
|
||||
|
||||
private static final float BALL_SIZE = 100f;
|
||||
|
||||
public final ArrayList<ShapeHolder> balls = new ArrayList<ShapeHolder>();
|
||||
Animatable animation = null;
|
||||
Animator animation = null;
|
||||
|
||||
public MyAnimationView(Context context) {
|
||||
super(context);
|
||||
@@ -83,28 +83,28 @@ public class AnimationLoading extends Activity {
|
||||
|
||||
private void createAnimation() {
|
||||
if (animation == null) {
|
||||
PropertyAnimator anim =
|
||||
(PropertyAnimator) AnimatableInflater.
|
||||
loadAnimatable(getApplicationContext(), R.anim.property_animator);
|
||||
ObjectAnimator anim =
|
||||
(ObjectAnimator) AnimatorInflater.
|
||||
loadAnimator(getApplicationContext(), R.anim.property_animator);
|
||||
anim.addUpdateListener(this);
|
||||
anim.setTarget(balls.get(0));
|
||||
|
||||
Animator fader =
|
||||
(Animator) AnimatableInflater.loadAnimatable(getApplicationContext(),
|
||||
ValueAnimator fader =
|
||||
(ValueAnimator) AnimatorInflater.loadAnimator(getApplicationContext(),
|
||||
R.anim.animator);
|
||||
fader.addUpdateListener(new Animator.AnimatorUpdateListener() {
|
||||
public void onAnimationUpdate(Animator animation) {
|
||||
fader.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
|
||||
public void onAnimationUpdate(ValueAnimator animation) {
|
||||
balls.get(1).setAlpha((Float) animation.getAnimatedValue());
|
||||
}
|
||||
});
|
||||
|
||||
Sequencer seq =
|
||||
(Sequencer) AnimatableInflater.loadAnimatable(getApplicationContext(),
|
||||
R.anim.sequencer);
|
||||
AnimatorSet seq =
|
||||
(AnimatorSet) AnimatorInflater.loadAnimator(getApplicationContext(),
|
||||
R.anim.animator_set);
|
||||
seq.setTarget(balls.get(2));
|
||||
|
||||
animation = new Sequencer();
|
||||
((Sequencer) animation).playTogether(anim, fader, seq);
|
||||
animation = new AnimatorSet();
|
||||
((AnimatorSet) animation).playTogether(anim, fader, seq);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -143,7 +143,7 @@ public class AnimationLoading extends Activity {
|
||||
}
|
||||
}
|
||||
|
||||
public void onAnimationUpdate(Animator animation) {
|
||||
public void onAnimationUpdate(ValueAnimator animation) {
|
||||
|
||||
invalidate();
|
||||
ShapeHolder ball = balls.get(0);
|
||||
|
||||
@@ -18,15 +18,14 @@ package com.example.android.apis.animation;
|
||||
|
||||
// Need the following import to get access to the app resources, since this
|
||||
// class is in a sub-package.
|
||||
import android.animation.Animator;
|
||||
import com.example.android.apis.R;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import android.animation.Animatable;
|
||||
import android.animation.Animator;
|
||||
import android.animation.PropertyAnimator;
|
||||
import android.animation.Sequencer;
|
||||
import android.animation.Animatable.AnimatableListener;
|
||||
import android.animation.ValueAnimator;
|
||||
import android.animation.ObjectAnimator;
|
||||
import android.animation.AnimatorSet;
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.graphics.Canvas;
|
||||
@@ -43,7 +42,7 @@ import android.widget.LinearLayout;
|
||||
import android.widget.SeekBar;
|
||||
|
||||
/**
|
||||
* This application demonstrates the seeking capability of Animator. The SeekBar in the
|
||||
* This application demonstrates the seeking capability of ValueAnimator. The SeekBar in the
|
||||
* UI allows you to set the position of the animation. Pressing the Run button will play from
|
||||
* the current position of the animation.
|
||||
*/
|
||||
@@ -93,7 +92,7 @@ public class AnimationSeeking extends Activity {
|
||||
});
|
||||
}
|
||||
|
||||
public class MyAnimationView extends View implements Animator.AnimatorUpdateListener, AnimatableListener {
|
||||
public class MyAnimationView extends View implements ValueAnimator.AnimatorUpdateListener, Animator.AnimatorListener {
|
||||
|
||||
private static final int RED = 0xffFF8080;
|
||||
private static final int BLUE = 0xff8080FF;
|
||||
@@ -102,8 +101,8 @@ public class AnimationSeeking extends Activity {
|
||||
private static final float BALL_SIZE = 100f;
|
||||
|
||||
public final ArrayList<ShapeHolder> balls = new ArrayList<ShapeHolder>();
|
||||
Sequencer animation = null;
|
||||
Animator bounceAnim = null;
|
||||
AnimatorSet animation = null;
|
||||
ValueAnimator bounceAnim = null;
|
||||
ShapeHolder ball = null;
|
||||
|
||||
public MyAnimationView(Context context) {
|
||||
@@ -113,7 +112,7 @@ public class AnimationSeeking extends Activity {
|
||||
|
||||
private void createAnimation() {
|
||||
if (bounceAnim == null) {
|
||||
bounceAnim = new PropertyAnimator(1500, ball, "y",
|
||||
bounceAnim = new ObjectAnimator(1500, ball, "y",
|
||||
ball.getY(), getHeight() - BALL_SIZE);
|
||||
bounceAnim.setInterpolator(new BounceInterpolator());
|
||||
bounceAnim.addUpdateListener(this);
|
||||
@@ -157,28 +156,28 @@ public class AnimationSeeking extends Activity {
|
||||
ball.getShape().draw(canvas);
|
||||
}
|
||||
|
||||
public void onAnimationUpdate(Animator animation) {
|
||||
public void onAnimationUpdate(ValueAnimator animation) {
|
||||
invalidate();
|
||||
long playtime = bounceAnim.getCurrentPlayTime();
|
||||
//mSeekBar.setProgress((int)playtime);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationCancel(Animatable animation) {
|
||||
public void onAnimationCancel(Animator animation) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationEnd(Animatable animation) {
|
||||
balls.remove(((PropertyAnimator)animation).getTarget());
|
||||
public void onAnimationEnd(Animator animation) {
|
||||
balls.remove(((ObjectAnimator)animation).getTarget());
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationRepeat(Animatable animation) {
|
||||
public void onAnimationRepeat(Animator animation) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationStart(Animatable animation) {
|
||||
public void onAnimationStart(Animator animation) {
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -18,16 +18,16 @@ package com.example.android.apis.animation;
|
||||
|
||||
// Need the following import to get access to the app resources, since this
|
||||
// class is in a sub-package.
|
||||
import android.animation.Animator;
|
||||
import android.animation.ObjectAnimator;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.TextView;
|
||||
import com.example.android.apis.R;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import android.animation.Animatable;
|
||||
import android.animation.Animator;
|
||||
import android.animation.PropertyAnimator;
|
||||
import android.animation.Sequencer;
|
||||
import android.animation.ValueAnimator;
|
||||
import android.animation.AnimatorSet;
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.graphics.Canvas;
|
||||
@@ -43,7 +43,7 @@ import android.widget.Button;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
/**
|
||||
* This demo shows how the AnimatableListener events work.
|
||||
* This demo shows how the AnimatorListener events work.
|
||||
*/
|
||||
public class AnimatorEvents extends Activity {
|
||||
|
||||
@@ -79,7 +79,6 @@ public class AnimatorEvents extends Activity {
|
||||
Button starter = (Button) findViewById(R.id.startButton);
|
||||
starter.setOnClickListener(new View.OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
animView.startAnimation(endCB.isChecked());
|
||||
}
|
||||
@@ -88,7 +87,6 @@ public class AnimatorEvents extends Activity {
|
||||
Button canceler = (Button) findViewById(R.id.cancelButton);
|
||||
canceler.setOnClickListener(new View.OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
animView.cancelAnimation();
|
||||
}
|
||||
@@ -97,7 +95,6 @@ public class AnimatorEvents extends Activity {
|
||||
Button ender = (Button) findViewById(R.id.endButton);
|
||||
ender.setOnClickListener(new View.OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
animView.endAnimation();
|
||||
}
|
||||
@@ -105,11 +102,11 @@ public class AnimatorEvents extends Activity {
|
||||
|
||||
}
|
||||
|
||||
public class MyAnimationView extends View implements Animatable.AnimatableListener,
|
||||
Animator.AnimatorUpdateListener {
|
||||
public class MyAnimationView extends View implements Animator.AnimatorListener,
|
||||
ValueAnimator.AnimatorUpdateListener {
|
||||
|
||||
public final ArrayList<ShapeHolder> balls = new ArrayList<ShapeHolder>();
|
||||
Animatable animation;
|
||||
Animator animation;
|
||||
ShapeHolder ball = null;
|
||||
boolean endImmediately = false;
|
||||
|
||||
@@ -120,28 +117,28 @@ public class AnimatorEvents extends Activity {
|
||||
|
||||
private void createAnimation() {
|
||||
if (animation == null) {
|
||||
PropertyAnimator yAnim = new PropertyAnimator(1500, ball, "y",
|
||||
ObjectAnimator yAnim = new ObjectAnimator(1500, ball, "y",
|
||||
ball.getY(), getHeight() - 50f);
|
||||
yAnim.setRepeatCount(0);
|
||||
yAnim.setRepeatMode(Animator.REVERSE);
|
||||
yAnim.setRepeatMode(ValueAnimator.REVERSE);
|
||||
yAnim.setInterpolator(new AccelerateInterpolator(2f));
|
||||
yAnim.addUpdateListener(this);
|
||||
yAnim.addListener(this);
|
||||
|
||||
PropertyAnimator xAnim = new PropertyAnimator(1000, ball, "x",
|
||||
ObjectAnimator xAnim = new ObjectAnimator(1000, ball, "x",
|
||||
ball.getX(), ball.getX() + 300);
|
||||
xAnim.setStartDelay(0);
|
||||
xAnim.setRepeatCount(0);
|
||||
xAnim.setRepeatMode(Animator.REVERSE);
|
||||
xAnim.setRepeatMode(ValueAnimator.REVERSE);
|
||||
xAnim.setInterpolator(new AccelerateInterpolator(2f));
|
||||
|
||||
PropertyAnimator alphaAnim = new PropertyAnimator(1000, ball, "alpha", 1f, .5f);
|
||||
Sequencer alphaSeq = new Sequencer();
|
||||
ObjectAnimator alphaAnim = new ObjectAnimator(1000, ball, "alpha", 1f, .5f);
|
||||
AnimatorSet alphaSeq = new AnimatorSet();
|
||||
alphaSeq.play(alphaAnim);
|
||||
|
||||
animation = new Sequencer();
|
||||
((Sequencer) animation).playTogether(yAnim, xAnim);
|
||||
//((Sequencer) animation).play(alphaSeq).after(500);
|
||||
animation = new AnimatorSet();
|
||||
((AnimatorSet) animation).playTogether(yAnim, xAnim);
|
||||
//((AnimatorSet) animation).play(alphaSeq).after(500);
|
||||
animation.addListener(this);
|
||||
}
|
||||
}
|
||||
@@ -198,12 +195,12 @@ public class AnimatorEvents extends Activity {
|
||||
canvas.restore();
|
||||
}
|
||||
|
||||
public void onAnimationUpdate(Animator animation) {
|
||||
public void onAnimationUpdate(ValueAnimator animation) {
|
||||
invalidate();
|
||||
}
|
||||
|
||||
public void onAnimationStart(Animatable animation) {
|
||||
if (animation instanceof Sequencer) {
|
||||
public void onAnimationStart(Animator animation) {
|
||||
if (animation instanceof AnimatorSet) {
|
||||
startText.setAlpha(1f);
|
||||
} else {
|
||||
startTextAnimator.setAlpha(1f);
|
||||
@@ -213,24 +210,24 @@ public class AnimatorEvents extends Activity {
|
||||
}
|
||||
}
|
||||
|
||||
public void onAnimationEnd(Animatable animation) {
|
||||
if (animation instanceof Sequencer) {
|
||||
public void onAnimationEnd(Animator animation) {
|
||||
if (animation instanceof AnimatorSet) {
|
||||
endText.setAlpha(1f);
|
||||
} else {
|
||||
endTextAnimator.setAlpha(1f);
|
||||
}
|
||||
}
|
||||
|
||||
public void onAnimationCancel(Animatable animation) {
|
||||
if (animation instanceof Sequencer) {
|
||||
public void onAnimationCancel(Animator animation) {
|
||||
if (animation instanceof AnimatorSet) {
|
||||
cancelText.setAlpha(1f);
|
||||
} else {
|
||||
cancelTextAnimator.setAlpha(1f);
|
||||
}
|
||||
}
|
||||
|
||||
public void onAnimationRepeat(Animatable animation) {
|
||||
if (animation instanceof Sequencer) {
|
||||
public void onAnimationRepeat(Animator animation) {
|
||||
if (animation instanceof AnimatorSet) {
|
||||
repeatText.setAlpha(1f);
|
||||
} else {
|
||||
repeatTextAnimator.setAlpha(1f);
|
||||
|
||||
@@ -50,7 +50,7 @@ public class BouncingBalls extends Activity {
|
||||
container.addView(new MyAnimationView(this));
|
||||
}
|
||||
|
||||
public class MyAnimationView extends View implements Animator.AnimatorUpdateListener, Animatable.AnimatableListener {
|
||||
public class MyAnimationView extends View implements ValueAnimator.AnimatorUpdateListener, Animator.AnimatorListener {
|
||||
|
||||
private static final int RED = 0xffFF8080;
|
||||
private static final int BLUE = 0xff8080FF;
|
||||
@@ -58,7 +58,7 @@ public class BouncingBalls extends Activity {
|
||||
private static final int GREEN = 0xff80ff80;
|
||||
|
||||
public final ArrayList<ShapeHolder> balls = new ArrayList<ShapeHolder>();
|
||||
Sequencer animation = null;
|
||||
AnimatorSet animation = null;
|
||||
|
||||
public MyAnimationView(Context context) {
|
||||
super(context);
|
||||
@@ -70,10 +70,10 @@ public class BouncingBalls extends Activity {
|
||||
paint.setColor(RED);
|
||||
|
||||
// Animate background color
|
||||
Animator colorAnim = new PropertyAnimator(3000, paint, "color", BLUE);
|
||||
ValueAnimator colorAnim = new ObjectAnimator(3000, paint, "color", BLUE);
|
||||
colorAnim.setEvaluator(new RGBEvaluator());
|
||||
colorAnim.setRepeatCount(Animator.INFINITE);
|
||||
colorAnim.setRepeatMode(Animator.REVERSE);
|
||||
colorAnim.setRepeatCount(ValueAnimator.INFINITE);
|
||||
colorAnim.setRepeatMode(ValueAnimator.REVERSE);
|
||||
colorAnim.addUpdateListener(this); // forces invalidation to get the redraw
|
||||
colorAnim.start();
|
||||
}
|
||||
@@ -92,33 +92,33 @@ public class BouncingBalls extends Activity {
|
||||
float h = (float)getHeight();
|
||||
float eventY = event.getY();
|
||||
int duration = (int)(500 * ((h - eventY)/h));
|
||||
Animator bounceAnim = new PropertyAnimator(duration, newBall, "y", startY, endY);
|
||||
ValueAnimator bounceAnim = new ObjectAnimator(duration, newBall, "y", startY, endY);
|
||||
bounceAnim.setInterpolator(new AccelerateInterpolator());
|
||||
Animator squashAnim1 = new PropertyAnimator(duration/4, newBall, "x", newBall.getX(),
|
||||
ValueAnimator squashAnim1 = new ObjectAnimator(duration/4, newBall, "x", newBall.getX(),
|
||||
newBall.getX() - 25f);
|
||||
squashAnim1.setRepeatCount(1);
|
||||
squashAnim1.setRepeatMode(Animator.REVERSE);
|
||||
squashAnim1.setRepeatMode(ValueAnimator.REVERSE);
|
||||
squashAnim1.setInterpolator(new DecelerateInterpolator());
|
||||
Animator squashAnim2 = new PropertyAnimator(duration/4, newBall, "width", newBall.getWidth(),
|
||||
ValueAnimator squashAnim2 = new ObjectAnimator(duration/4, newBall, "width", newBall.getWidth(),
|
||||
newBall.getWidth() + 50);
|
||||
squashAnim2.setRepeatCount(1);
|
||||
squashAnim2.setRepeatMode(Animator.REVERSE);
|
||||
squashAnim2.setRepeatMode(ValueAnimator.REVERSE);
|
||||
squashAnim2.setInterpolator(new DecelerateInterpolator());
|
||||
Animator stretchAnim1 = new PropertyAnimator(duration/4, newBall, "y", endY,
|
||||
ValueAnimator stretchAnim1 = new ObjectAnimator(duration/4, newBall, "y", endY,
|
||||
endY + 25f);
|
||||
stretchAnim1.setRepeatCount(1);
|
||||
stretchAnim1.setInterpolator(new DecelerateInterpolator());
|
||||
stretchAnim1.setRepeatMode(Animator.REVERSE);
|
||||
Animator stretchAnim2 = new PropertyAnimator(duration/4, newBall, "height",
|
||||
stretchAnim1.setRepeatMode(ValueAnimator.REVERSE);
|
||||
ValueAnimator stretchAnim2 = new ObjectAnimator(duration/4, newBall, "height",
|
||||
newBall.getHeight(), newBall.getHeight() - 25);
|
||||
stretchAnim2.setRepeatCount(1);
|
||||
stretchAnim2.setInterpolator(new DecelerateInterpolator());
|
||||
stretchAnim2.setRepeatMode(Animator.REVERSE);
|
||||
Animator bounceBackAnim = new PropertyAnimator(duration, newBall, "y", endY,
|
||||
stretchAnim2.setRepeatMode(ValueAnimator.REVERSE);
|
||||
ValueAnimator bounceBackAnim = new ObjectAnimator(duration, newBall, "y", endY,
|
||||
startY);
|
||||
bounceBackAnim.setInterpolator(new DecelerateInterpolator());
|
||||
// Sequence the down/squash&stretch/up animations
|
||||
Sequencer bouncer = new Sequencer();
|
||||
AnimatorSet bouncer = new AnimatorSet();
|
||||
bouncer.play(bounceAnim).before(squashAnim1);
|
||||
bouncer.play(squashAnim1).with(squashAnim2);
|
||||
bouncer.play(squashAnim1).with(stretchAnim1);
|
||||
@@ -126,15 +126,15 @@ public class BouncingBalls extends Activity {
|
||||
bouncer.play(bounceBackAnim).after(stretchAnim2);
|
||||
|
||||
// Fading animation - remove the ball when the animation is done
|
||||
Animator fadeAnim = new PropertyAnimator(250, newBall, "alpha", 1f, 0f);
|
||||
ValueAnimator fadeAnim = new ObjectAnimator(250, newBall, "alpha", 1f, 0f);
|
||||
fadeAnim.addListener(this);
|
||||
|
||||
// Sequence the two animations to play one after the other
|
||||
Sequencer sequencer = new Sequencer();
|
||||
sequencer.play(bouncer).before(fadeAnim);
|
||||
AnimatorSet animatorSet = new AnimatorSet();
|
||||
animatorSet.play(bouncer).before(fadeAnim);
|
||||
|
||||
// Start the animation
|
||||
sequencer.start();
|
||||
animatorSet.start();
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -171,26 +171,26 @@ public class BouncingBalls extends Activity {
|
||||
}
|
||||
}
|
||||
|
||||
public void onAnimationUpdate(Animator animation) {
|
||||
public void onAnimationUpdate(ValueAnimator animation) {
|
||||
invalidate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationCancel(Animatable animation) {
|
||||
public void onAnimationCancel(Animator animation) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationEnd(Animatable animation) {
|
||||
balls.remove(((PropertyAnimator)animation).getTarget());
|
||||
public void onAnimationEnd(Animator animation) {
|
||||
balls.remove(((ObjectAnimator)animation).getTarget());
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationRepeat(Animatable animation) {
|
||||
public void onAnimationRepeat(Animator animation) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationStart(Animatable animation) {
|
||||
public void onAnimationStart(Animator animation) {
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -18,16 +18,13 @@ package com.example.android.apis.animation;
|
||||
|
||||
// Need the following import to get access to the app resources, since this
|
||||
// class is in a sub-package.
|
||||
import android.animation.ObjectAnimator;
|
||||
import android.animation.TypeEvaluator;
|
||||
import android.animation.ValueAnimator;
|
||||
import com.example.android.apis.R;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import android.animation.Animatable;
|
||||
import android.animation.Animator;
|
||||
import android.animation.PropertyAnimator;
|
||||
import android.animation.Sequencer;
|
||||
import android.animation.Animatable.AnimatableListener;
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.graphics.Canvas;
|
||||
@@ -38,7 +35,6 @@ import android.graphics.drawable.ShapeDrawable;
|
||||
import android.graphics.drawable.shapes.OvalShape;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.view.animation.AccelerateInterpolator;
|
||||
import android.widget.Button;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
@@ -117,10 +113,10 @@ public class CustomEvaluator extends Activity {
|
||||
}
|
||||
}
|
||||
|
||||
public class MyAnimationView extends View implements Animator.AnimatorUpdateListener {
|
||||
public class MyAnimationView extends View implements ValueAnimator.AnimatorUpdateListener {
|
||||
|
||||
public final ArrayList<ShapeHolder> balls = new ArrayList<ShapeHolder>();
|
||||
Animator bounceAnim = null;
|
||||
ValueAnimator bounceAnim = null;
|
||||
ShapeHolder ball = null;
|
||||
BallXYHolder ballHolder = null;
|
||||
|
||||
@@ -134,7 +130,7 @@ public class CustomEvaluator extends Activity {
|
||||
if (bounceAnim == null) {
|
||||
XYHolder startXY = new XYHolder(0f, 0f);
|
||||
XYHolder endXY = new XYHolder(300f, 500f);
|
||||
bounceAnim = new PropertyAnimator(1500, ballHolder, "xY",
|
||||
bounceAnim = new ObjectAnimator(1500, ballHolder, "xY",
|
||||
endXY);
|
||||
bounceAnim.setEvaluator(new XYEvaluator());
|
||||
bounceAnim.addUpdateListener(this);
|
||||
@@ -174,7 +170,7 @@ public class CustomEvaluator extends Activity {
|
||||
canvas.restore();
|
||||
}
|
||||
|
||||
public void onAnimationUpdate(Animator animation) {
|
||||
public void onAnimationUpdate(ValueAnimator animation) {
|
||||
invalidate();
|
||||
}
|
||||
|
||||
|
||||
@@ -18,13 +18,13 @@ package com.example.android.apis.animation;
|
||||
|
||||
// Need the following import to get access to the app resources, since this
|
||||
// class is in a sub-package.
|
||||
import android.animation.Animator;
|
||||
import android.animation.ObjectAnimator;
|
||||
import com.example.android.apis.R;
|
||||
|
||||
import android.animation.Animatable;
|
||||
import android.animation.AnimatableListenerAdapter;
|
||||
import android.animation.AnimatorListenerAdapter;
|
||||
import android.animation.Keyframe;
|
||||
import android.animation.LayoutTransition;
|
||||
import android.animation.PropertyAnimator;
|
||||
import android.animation.PropertyValuesHolder;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
@@ -36,7 +36,7 @@ import android.os.Bundle;
|
||||
import android.widget.Button;
|
||||
|
||||
/**
|
||||
* This application demonstrates the seeking capability of Animator. The SeekBar in the
|
||||
* This application demonstrates the seeking capability of ValueAnimator. The SeekBar in the
|
||||
* UI allows you to set the position of the animation. Pressing the Run button will play from
|
||||
* the current position of the animation.
|
||||
*/
|
||||
@@ -85,10 +85,10 @@ public class LayoutAnimations extends Activity {
|
||||
} else {
|
||||
transitioner.setStagger(LayoutTransition.CHANGE_APPEARING, 0);
|
||||
transitioner.setStagger(LayoutTransition.CHANGE_DISAPPEARING, 0);
|
||||
transitioner.setAnimatable(LayoutTransition.APPEARING, null);
|
||||
transitioner.setAnimatable(LayoutTransition.DISAPPEARING, null);
|
||||
transitioner.setAnimatable(LayoutTransition.CHANGE_APPEARING, null);
|
||||
transitioner.setAnimatable(LayoutTransition.CHANGE_DISAPPEARING, null);
|
||||
transitioner.setAnimator(LayoutTransition.APPEARING, null);
|
||||
transitioner.setAnimator(LayoutTransition.DISAPPEARING, null);
|
||||
transitioner.setAnimator(LayoutTransition.CHANGE_APPEARING, null);
|
||||
transitioner.setAnimator(LayoutTransition.CHANGE_DISAPPEARING, null);
|
||||
duration = 300;
|
||||
}
|
||||
transitioner.setDuration(duration);
|
||||
@@ -110,13 +110,13 @@ public class LayoutAnimations extends Activity {
|
||||
new PropertyValuesHolder<Float>("scaleX", 1f, 0f, 1f);
|
||||
PropertyValuesHolder<Float> pvhScaleY =
|
||||
new PropertyValuesHolder<Float>("scaleY", 1f, 0f, 1f);
|
||||
final PropertyAnimator changeIn =
|
||||
new PropertyAnimator(transition.getDuration(LayoutTransition.CHANGE_APPEARING),
|
||||
final ObjectAnimator changeIn =
|
||||
new ObjectAnimator(transition.getDuration(LayoutTransition.CHANGE_APPEARING),
|
||||
this, pvhLeft, pvhTop, pvhRight, pvhBottom, pvhScaleX, pvhScaleY);
|
||||
transition.setAnimatable(LayoutTransition.CHANGE_APPEARING, changeIn);
|
||||
changeIn.addListener(new AnimatableListenerAdapter() {
|
||||
public void onAnimationEnd(Animatable anim) {
|
||||
View view = (View) ((PropertyAnimator) anim).getTarget();
|
||||
transition.setAnimator(LayoutTransition.CHANGE_APPEARING, changeIn);
|
||||
changeIn.addListener(new AnimatorListenerAdapter() {
|
||||
public void onAnimationEnd(Animator anim) {
|
||||
View view = (View) ((ObjectAnimator) anim).getTarget();
|
||||
view.setScaleX(1f);
|
||||
view.setScaleY(1f);
|
||||
}
|
||||
@@ -128,37 +128,37 @@ public class LayoutAnimations extends Activity {
|
||||
Keyframe kf2 = new Keyframe(1f, 0f);
|
||||
PropertyValuesHolder<Keyframe> pvhRotation =
|
||||
new PropertyValuesHolder<Keyframe>("rotation", kf0, kf1, kf2);
|
||||
final PropertyAnimator changeOut =
|
||||
new PropertyAnimator(transition.getDuration(LayoutTransition.CHANGE_DISAPPEARING),
|
||||
final ObjectAnimator changeOut =
|
||||
new ObjectAnimator(transition.getDuration(LayoutTransition.CHANGE_DISAPPEARING),
|
||||
this, pvhLeft, pvhTop, pvhRight, pvhBottom, pvhRotation);
|
||||
transition.setAnimatable(LayoutTransition.CHANGE_DISAPPEARING, changeOut);
|
||||
changeOut.addListener(new AnimatableListenerAdapter() {
|
||||
public void onAnimationEnd(Animatable anim) {
|
||||
View view = (View) ((PropertyAnimator) anim).getTarget();
|
||||
transition.setAnimator(LayoutTransition.CHANGE_DISAPPEARING, changeOut);
|
||||
changeOut.addListener(new AnimatorListenerAdapter() {
|
||||
public void onAnimationEnd(Animator anim) {
|
||||
View view = (View) ((ObjectAnimator) anim).getTarget();
|
||||
view.setRotation(0f);
|
||||
}
|
||||
});
|
||||
|
||||
// Adding
|
||||
PropertyAnimator<Float> animIn =
|
||||
new PropertyAnimator<Float>(transition.getDuration(LayoutTransition.APPEARING),
|
||||
ObjectAnimator<Float> animIn =
|
||||
new ObjectAnimator<Float>(transition.getDuration(LayoutTransition.APPEARING),
|
||||
null, "rotationY", 90f, 0f);
|
||||
transition.setAnimatable(LayoutTransition.APPEARING, animIn);
|
||||
animIn.addListener(new AnimatableListenerAdapter() {
|
||||
public void onAnimationEnd(Animatable anim) {
|
||||
View view = (View) ((PropertyAnimator) anim).getTarget();
|
||||
transition.setAnimator(LayoutTransition.APPEARING, animIn);
|
||||
animIn.addListener(new AnimatorListenerAdapter() {
|
||||
public void onAnimationEnd(Animator anim) {
|
||||
View view = (View) ((ObjectAnimator) anim).getTarget();
|
||||
view.setRotationY(0f);
|
||||
}
|
||||
});
|
||||
|
||||
// Removing
|
||||
PropertyAnimator<Float> animOut =
|
||||
new PropertyAnimator<Float>(transition.getDuration(LayoutTransition.DISAPPEARING),
|
||||
ObjectAnimator<Float> animOut =
|
||||
new ObjectAnimator<Float>(transition.getDuration(LayoutTransition.DISAPPEARING),
|
||||
null, "rotationX", 0f, 90f);
|
||||
transition.setAnimatable(LayoutTransition.DISAPPEARING, animOut);
|
||||
animIn.addListener(new AnimatableListenerAdapter() {
|
||||
public void onAnimationEnd(Animatable anim) {
|
||||
View view = (View) ((PropertyAnimator) anim).getTarget();
|
||||
transition.setAnimator(LayoutTransition.DISAPPEARING, animOut);
|
||||
animIn.addListener(new AnimatorListenerAdapter() {
|
||||
public void onAnimationEnd(Animator anim) {
|
||||
View view = (View) ((ObjectAnimator) anim).getTarget();
|
||||
view.setRotationX(0f);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -20,23 +20,15 @@ package com.example.android.apis.animation;
|
||||
// class is in a sub-package.
|
||||
import com.example.android.apis.R;
|
||||
|
||||
import android.animation.Animatable;
|
||||
import android.animation.AnimatableListenerAdapter;
|
||||
import android.animation.Keyframe;
|
||||
import android.animation.LayoutTransition;
|
||||
import android.animation.PropertyAnimator;
|
||||
import android.animation.PropertyValuesHolder;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.CompoundButton;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.os.Bundle;
|
||||
import android.widget.Button;
|
||||
|
||||
/**
|
||||
* This application demonstrates the seeking capability of Animator. The SeekBar in the
|
||||
* This application demonstrates the seeking capability of ValueAnimator. The SeekBar in the
|
||||
* UI allows you to set the position of the animation. Pressing the Run button will play from
|
||||
* the current position of the animation.
|
||||
*/
|
||||
|
||||
@@ -18,39 +18,24 @@ package com.example.android.apis.animation;
|
||||
|
||||
// Need the following import to get access to the app resources, since this
|
||||
// class is in a sub-package.
|
||||
import android.animation.AnimatableListenerAdapter;
|
||||
import android.animation.AnimatorListenerAdapter;
|
||||
import android.animation.Animator;
|
||||
import android.animation.ObjectAnimator;
|
||||
import android.view.animation.AccelerateInterpolator;
|
||||
import android.view.animation.DecelerateInterpolator;
|
||||
import android.view.animation.Interpolator;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ListView;
|
||||
import com.example.android.apis.R;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import android.animation.Animatable;
|
||||
import android.animation.Animator;
|
||||
import android.animation.PropertyAnimator;
|
||||
import android.animation.Sequencer;
|
||||
import android.animation.Animatable.AnimatableListener;
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.RadialGradient;
|
||||
import android.graphics.Shader;
|
||||
import android.graphics.drawable.ShapeDrawable;
|
||||
import android.graphics.drawable.shapes.OvalShape;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.view.animation.BounceInterpolator;
|
||||
import android.widget.Button;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.SeekBar;
|
||||
|
||||
/**
|
||||
* This application demonstrates the seeking capability of Animator. The SeekBar in the
|
||||
* This application demonstrates the seeking capability of ValueAnimator. The SeekBar in the
|
||||
* UI allows you to set the position of the animation. Pressing the Run button will play from
|
||||
* the current position of the animation.
|
||||
*/
|
||||
@@ -121,13 +106,13 @@ public class ListFlipper extends Activity {
|
||||
invisibleList = mFrenchList;
|
||||
visibleList = mEnglishList;
|
||||
}
|
||||
PropertyAnimator visToInvis = new PropertyAnimator(500, visibleList, "rotationY", 0f, 90f);
|
||||
ObjectAnimator visToInvis = new ObjectAnimator(500, visibleList, "rotationY", 0f, 90f);
|
||||
visToInvis.setInterpolator(accelerator);
|
||||
final PropertyAnimator invisToVis = new PropertyAnimator(500, invisibleList, "rotationY", -90f, 0f);
|
||||
final ObjectAnimator invisToVis = new ObjectAnimator(500, invisibleList, "rotationY", -90f, 0f);
|
||||
invisToVis.setInterpolator(decelerator);
|
||||
visToInvis.addListener(new AnimatableListenerAdapter() {
|
||||
visToInvis.addListener(new AnimatorListenerAdapter() {
|
||||
@Override
|
||||
public void onAnimationEnd(Animatable anim) {
|
||||
public void onAnimationEnd(Animator anim) {
|
||||
visibleList.setVisibility(View.GONE);
|
||||
invisToVis.start();
|
||||
invisibleList.setVisibility(View.VISIBLE);
|
||||
|
||||
@@ -24,7 +24,6 @@ import com.example.android.apis.R;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import android.animation.Animatable.AnimatableListener;
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.graphics.Canvas;
|
||||
@@ -38,10 +37,9 @@ import android.view.View;
|
||||
import android.view.animation.BounceInterpolator;
|
||||
import android.widget.Button;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.SeekBar;
|
||||
|
||||
/**
|
||||
* This application demonstrates the seeking capability of Animator. The SeekBar in the
|
||||
* This application demonstrates the seeking capability of ValueAnimator. The SeekBar in the
|
||||
* UI allows you to set the position of the animation. Pressing the Run button will play from
|
||||
* the current position of the animation.
|
||||
*/
|
||||
@@ -60,7 +58,6 @@ public class MultiPropertyAnimation extends Activity {
|
||||
Button starter = (Button) findViewById(R.id.startButton);
|
||||
starter.setOnClickListener(new View.OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
animView.startAnimation();
|
||||
}
|
||||
@@ -68,13 +65,13 @@ public class MultiPropertyAnimation extends Activity {
|
||||
|
||||
}
|
||||
|
||||
public class MyAnimationView extends View implements Animator.AnimatorUpdateListener {
|
||||
public class MyAnimationView extends View implements ValueAnimator.AnimatorUpdateListener {
|
||||
|
||||
private static final float BALL_SIZE = 100f;
|
||||
|
||||
public final ArrayList<ShapeHolder> balls = new ArrayList<ShapeHolder>();
|
||||
Sequencer animation = null;
|
||||
Animatable bounceAnim = null;
|
||||
AnimatorSet animation = null;
|
||||
Animator bounceAnim = null;
|
||||
ShapeHolder ball = null;
|
||||
|
||||
public MyAnimationView(Context context) {
|
||||
@@ -89,7 +86,7 @@ public class MultiPropertyAnimation extends Activity {
|
||||
if (bounceAnim == null) {
|
||||
ShapeHolder ball;
|
||||
ball = balls.get(0);
|
||||
PropertyAnimator yBouncer = new PropertyAnimator(DURATION, ball, "y",
|
||||
ObjectAnimator yBouncer = new ObjectAnimator(DURATION, ball, "y",
|
||||
ball.getY(), getHeight() - BALL_SIZE);
|
||||
yBouncer.setInterpolator(new BounceInterpolator());
|
||||
yBouncer.addUpdateListener(this);
|
||||
@@ -99,10 +96,10 @@ public class MultiPropertyAnimation extends Activity {
|
||||
getHeight() - BALL_SIZE);
|
||||
PropertyValuesHolder pvhAlpha = new PropertyValuesHolder("alpha", 1.0f,
|
||||
0f);
|
||||
PropertyAnimator yAlphaBouncer = new PropertyAnimator(DURATION/2, ball, pvhY, pvhAlpha);
|
||||
ObjectAnimator yAlphaBouncer = new ObjectAnimator(DURATION/2, ball, pvhY, pvhAlpha);
|
||||
yAlphaBouncer.setInterpolator(new AccelerateInterpolator());
|
||||
yAlphaBouncer.setRepeatCount(1);
|
||||
yAlphaBouncer.setRepeatMode(Animator.REVERSE);
|
||||
yAlphaBouncer.setRepeatMode(ValueAnimator.REVERSE);
|
||||
|
||||
|
||||
ball = balls.get(2);
|
||||
@@ -112,10 +109,10 @@ public class MultiPropertyAnimation extends Activity {
|
||||
ball.getHeight() * 2);
|
||||
PropertyValuesHolder pvTX = new PropertyValuesHolder("x", ball.getX(), ball.getX() - BALL_SIZE/2f);
|
||||
PropertyValuesHolder pvTY = new PropertyValuesHolder("y", 0f, ball.getY(), ball.getY() - BALL_SIZE/2f);
|
||||
PropertyAnimator whxyBouncer = new PropertyAnimator(DURATION/2, ball, pvhW, pvhH,
|
||||
ObjectAnimator whxyBouncer = new ObjectAnimator(DURATION/2, ball, pvhW, pvhH,
|
||||
pvTX, pvTY);
|
||||
whxyBouncer.setRepeatCount(1);
|
||||
whxyBouncer.setRepeatMode(Animator.REVERSE);
|
||||
whxyBouncer.setRepeatMode(ValueAnimator.REVERSE);
|
||||
|
||||
ball = balls.get(3);
|
||||
pvhY = new PropertyValuesHolder("y", ball.getY(),
|
||||
@@ -125,13 +122,13 @@ public class MultiPropertyAnimation extends Activity {
|
||||
Keyframe kf1 = new Keyframe(.5f, ballX + 100f);
|
||||
Keyframe kf2 = new Keyframe(1f, ballX + 50f);
|
||||
PropertyValuesHolder pvhX = new PropertyValuesHolder("x", kf0, kf1, kf2);
|
||||
PropertyAnimator yxBouncer = new PropertyAnimator(DURATION/2, ball, pvhY, pvhX);
|
||||
ObjectAnimator yxBouncer = new ObjectAnimator(DURATION/2, ball, pvhY, pvhX);
|
||||
yxBouncer.setRepeatCount(1);
|
||||
yxBouncer.setRepeatMode(Animator.REVERSE);
|
||||
yxBouncer.setRepeatMode(ValueAnimator.REVERSE);
|
||||
|
||||
|
||||
bounceAnim = new Sequencer();
|
||||
((Sequencer)bounceAnim).playTogether(yBouncer, yAlphaBouncer, whxyBouncer, yxBouncer);
|
||||
bounceAnim = new AnimatorSet();
|
||||
((AnimatorSet)bounceAnim).playTogether(yBouncer, yAlphaBouncer, whxyBouncer, yxBouncer);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -170,7 +167,7 @@ public class MultiPropertyAnimation extends Activity {
|
||||
}
|
||||
}
|
||||
|
||||
public void onAnimationUpdate(Animator animation) {
|
||||
public void onAnimationUpdate(ValueAnimator animation) {
|
||||
invalidate();
|
||||
}
|
||||
|
||||
|
||||
@@ -18,15 +18,12 @@ package com.example.android.apis.animation;
|
||||
|
||||
// Need the following import to get access to the app resources, since this
|
||||
// class is in a sub-package.
|
||||
import android.animation.ObjectAnimator;
|
||||
import android.animation.ValueAnimator;
|
||||
import com.example.android.apis.R;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import android.animation.Animatable;
|
||||
import android.animation.Animator;
|
||||
import android.animation.PropertyAnimator;
|
||||
import android.animation.Sequencer;
|
||||
import android.animation.Animatable.AnimatableListener;
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.graphics.Canvas;
|
||||
@@ -71,10 +68,10 @@ public class ReversingAnimation extends Activity {
|
||||
|
||||
}
|
||||
|
||||
public class MyAnimationView extends View implements Animator.AnimatorUpdateListener {
|
||||
public class MyAnimationView extends View implements ValueAnimator.AnimatorUpdateListener {
|
||||
|
||||
public final ArrayList<ShapeHolder> balls = new ArrayList<ShapeHolder>();
|
||||
Animator bounceAnim = null;
|
||||
ValueAnimator bounceAnim = null;
|
||||
ShapeHolder ball = null;
|
||||
|
||||
public MyAnimationView(Context context) {
|
||||
@@ -84,7 +81,7 @@ public class ReversingAnimation extends Activity {
|
||||
|
||||
private void createAnimation() {
|
||||
if (bounceAnim == null) {
|
||||
bounceAnim = new PropertyAnimator(1500, ball, "y",
|
||||
bounceAnim = new ObjectAnimator(1500, ball, "y",
|
||||
ball.getY(), getHeight() - 50f);
|
||||
bounceAnim.setInterpolator(new AccelerateInterpolator(2f));
|
||||
bounceAnim.addUpdateListener(this);
|
||||
@@ -134,7 +131,7 @@ public class ReversingAnimation extends Activity {
|
||||
canvas.restore();
|
||||
}
|
||||
|
||||
public void onAnimationUpdate(Animator animation) {
|
||||
public void onAnimationUpdate(ValueAnimator animation) {
|
||||
invalidate();
|
||||
}
|
||||
|
||||
|
||||
@@ -23,11 +23,10 @@ import com.example.android.apis.R;
|
||||
import android.app.Activity;
|
||||
import android.os.Bundle;
|
||||
import android.widget.Button;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.SeekBar;
|
||||
|
||||
/**
|
||||
* This application demonstrates the seeking capability of Animator. The SeekBar in the
|
||||
* This application demonstrates the seeking capability of ValueAnimator. The SeekBar in the
|
||||
* UI allows you to set the position of the animation. Pressing the Run button will play from
|
||||
* the current position of the animation.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user