Android implements Flip flip animation

  • 2020-06-07 05:16:46
  • OfStack

The example of this paper describes the Android to achieve the Flip flip animation effect method, to share for your reference.

The specific implementation code is as follows:


LinearLayout locationLL = (LinearLayout) findViewById(R.id.locationLL);
LinearLayout baseLL = (LinearLayout) findViewById(R.id.baseLL);

private void flipit() {
 Interpolator accelerator = new AccelerateInterpolator();
 Interpolator decelerator = new DecelerateInterpolator();
    final LinearLayout visibleList,invisibleList;
    final ObjectAnimator visToInvis, invisToVis;
    if (locationLL.getVisibility() == View.GONE) {
      visibleList = baseLL;
      invisibleList = locationLL;
      visToInvis = ObjectAnimator.ofFloat(visibleList, "rotationY", 0f, 90f);
      invisToVis = ObjectAnimator.ofFloat(invisibleList, "rotationY", -90f, 0f);
    } else {
      invisibleList = baseLL;
      visibleList = locationLL;
      visToInvis = ObjectAnimator.ofFloat(visibleList, "rotationY", 0f, -90f);
      invisToVis = ObjectAnimator.ofFloat(invisibleList, "rotationY", 90f, 0f);
    }
    visToInvis.setDuration(300);
    invisToVis.setDuration(300);
    visToInvis.setInterpolator(accelerator);
    invisToVis.setInterpolator(decelerator);
    visToInvis.addListener(new AnimatorListenerAdapter() {
      @Override
      public void onAnimationEnd(Animator anim) {
        visibleList.setVisibility(View.GONE);
        invisToVis.start();
        invisibleList.setVisibility(View.VISIBLE);
      }
    });
    visToInvis.start();
}

I hope the examples described in this article will be of some help to Android programming.


Related articles: