//自定义的圆
public class Donghua extends View {
Paint paint;
public Donghua(Context context, AttributeSet attrs) {
super(context, attrs);
}
@Override
public void draw(Canvas canvas) {
super.draw(canvas);
paint=new Paint();
paint.setColor(Color.RED);
paint.setStyle(Paint.Style.FILL);
paint.setStrokeWidth(8);
canvas.drawCircle(getWidth()/2,getHeight()/2,50,paint);
}
动画
ObjectAnimator translationX = ObjectAnimator.ofFloat(donghua, "translationX", 0f,800f);
ObjectAnimator translationY = ObjectAnimator.ofFloat(donghua, "translationY", 0f, 1200f);
AnimatorSet animatorSet=new AnimatorSet();
animatorSet.play(translationX).with(translationY);
animatorSet.setDuration(3000);
animatorSet.start();
animatorSet.addListener(new Animator.AnimatorListener() {
@Override
public void onAnimationStart(Animator animation) {
}
@Override
public void onAnimationEnd(Animator animation) {
Intent intent=new Intent(MainActivity.this,SecondActivity.class);
startActivity(intent);
}
@Override
public void onAnimationCancel(Animator animation) {
}
@Override
public void onAnimationRepeat(Animator animation) {
}
});
}