LoginSignup
6
7

More than 5 years have passed since last update.

Viewをパスに沿ってアニメーションさせる

Last updated at Posted at 2013-02-14

Viewに複雑な動きを要求されたことはないですか。
そういう時に複雑な動きを簡単に実現させる方法を紹介します。

下記よりPathAnimation.javaをダウンロードし、プロジェクトにインポートします。
- https://github.com/coocood/PathAnimation

Activityに以下のように書けばViewがパスに沿ってアニメーションします。
- パスはPathクラスのインスタンスに設定していきます。

Path path = new Path();
path.moveTo(0, 0);
path.addArc(new RectF(120, 63, 190, 127), 180, 180);
PathAnimation animation = new PathAnimation(path);
animation.setRepeatCount(1);
animation.setDuration(1000);
view.startAnimation(animation);

アニメーションの時間や繰り返し回数はPathAnimationクラスに設定します。これでかなり複雑な動きもあらかじめパスとして与えるだけで実現できるようになります。

6
7
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
7