Skip to content

Item: Animation

三木思 edited this page Nov 6, 2018 · 4 revisions

When use

TimoMenu.addRow(ItemAnimation itemAnimation, List<TimoItemViewParameter> timoItemViewParameters)

or

TimoMenu.Builder.addRow(ItemAnimation itemAnimation, List<TimoItemViewParameter> timoItemViewParameters)

You need to pass an itemAnimation parameter, it define a base class that allows you to customize the opening animation of the item.

public abstract class ItemAnimation {
    /**
     * Get the animation when the menu is showing.
     *
     * @param itemView The item view.
     * @param positionOfVisibleViews The position in all visible views of the row.
     * @return The animation that executed when the item view is displayed.
     * */
    public abstract Animation getAnimation(TimoItemView itemView, int positionOfVisibleViews);

    /**
     *  Get the animator when the menu is showing.
     *
     * @param itemView The item view.
     * @param positionOfVisibleViews The position in all visible views of the row.
     * @return The animation that executed when the item view is displayed.
     * */
    public abstract Animator getAnimator(TimoItemView itemView, int positionOfVisibleViews);
}

In this base class, you can specify whether to use Animation or Animator.

I have defined 8 animations in this library including reference daimajia/AndroidViewAnimations.

  1. FlipItemAnimation
  2. ScaleItemAnimation
  3. BombItemAnimation
  4. StandUpItemAnimation
  5. BounceItemAnimation
  6. BounceInDownItemAnimation
  7. BounceInUpItemAnimation
  8. RotateItemAnimation

You can refer to the below picture:

item animations

Note

About the parameter 'positionOfVisibleViews', let's look at the below picture

position

In the row of menu, there are 6 items, but only 4 are visible, item2, item3, item4, item5.

So the position of visible views representative:

  • item2 : position = 0
  • item3 : position = 1
  • item4 : position = 2
  • item5 : position = 3

Clone this wiki locally