欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  移动技术

Android实现Flip翻转动画效果

程序员文章站 2022-11-05 14:45:25
本文实例讲述了android实现flip翻转动画效果的方法,分享给大家供大家学习借鉴。 具体实现代码如下: linearlayout locationll =...

本文实例讲述了android实现flip翻转动画效果的方法,分享给大家供大家学习借鉴。

具体实现代码如下:

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();
}

希望本文所述实例对大家android程序设计能有一定的帮助。