What is the difference between an Animator and an Animation?

前端 未结 2 687
萌比男神i
萌比男神i 2020-12-02 12:00

It looks like both Animations and Animators allow me to animate properties (position, opacity, scale, rotation, etc) on objects, and I\'m having a hard time differentiating

2条回答
  •  清歌不尽
    2020-12-02 12:27

    An Animation object animate the view's image. If you use this for example, to move a button around the screen you will not be able to click on it at the new visible position because it was not truly moved, but only his bitmap representation was translated. You will also not be able to change the proportions of it since you are making modifications to a bitmap. If you use xml files, place them at anim folder.

    An Animator object animate the view's property (like the margin or width). If you use this to move a button around the screen you will be able to capture clicks on it in the new visible positions. If you use xml files, place them at animator folder.

    If you only need cosmetic effects, like fade in or small appearance translation, using a Animation will be more efficient because it does not call layout() or measure() methods. If you do need to capture actions like click events, use a Animator.

提交回复
热议问题