用Android rotate动画实现翻页效果,效果如图:

![](http://img.blog.csdn.net/20130826221333046?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvaHVhemFpOTYzMTg0NzA5/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast)





要实现上面动画,首先搞明白rotate动画原理;





(1)Degrees坐标:





                      0度(360度)





  270度![](http://img.blog.csdn.net/20130826214747859?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvaHVhemFpOTYzMTg0NzA5/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast) 90度  顺时针旋转





                        180





(2)rotate 关键属性





        fromDegrees 开始旋转时角度      toDegrees 结束时的角度





        pivotX,pivotY 旋转时的中心点  他们范围是 0—100%p   (0,0)代表左上角,(100%p, 100%p)右下角





        duration 动画持续时间 毫秒为单位





知道了这两点就可以实现了   在res新建 anim 文件夹





   新建 离开Activity时的xml
**[html]** [view plain](http://blog.csdn.net/huazai963184709/article/details/10364243#)[copy](http://blog.csdn.net/huazai963184709/article/details/10364243#)[print](http://blog.csdn.net/huazai963184709/article/details/10364243#)[?](http://blog.csdn.net/huazai963184709/article/details/10364243#)
- <span style="color: black;"><span class="tag" style="font-weight: bold; color: #993300;"><?</span><span class="tag-name" style="font-weight: bold; color: #993300;">xml</span> <span class="attribute" style="color: red;">version</span>=<span class="attribute-value" style="color: blue;">&#8220;1.0&#8221;</span> <span class="attribute" style="color: red;">encoding</span>=<span class="attribute-value" style="color: blue;">&#8220;utf-8&#8221;</span><span class="tag" style="font-weight: bold; color: #993300;">?></span>  </span>

- <span style="color: black;"><span class="tag" style="font-weight: bold; color: #993300;"><</span><span class="tag-name" style="font-weight: bold; color: #993300;">set</span> <span class="attribute" style="color: red;">xmlns:android</span>=<span class="attribute-value" style="color: blue;">&#8220;http://schemas.android.com/apk/res/android&#8221;</span> <span class="tag" style="font-weight: bold; color: #993300;">></span>  </span>

- <span style="color: black;">  </span>

- <span style="color: black;">    <span class="tag" style="font-weight: bold; color: #993300;"><</span><span class="tag-name" style="font-weight: bold; color: #993300;">rotate</span>  </span>

- <span style="color: black;">        <span class="attribute" style="color: red;">android:duration</span>=<span class="attribute-value" style="color: blue;">&#8220;500&#8221;</span>  </span>

- <span style="color: black;">        <span class="attribute" style="color: red;">android:fromDegrees</span>=<span class="attribute-value" style="color: blue;">&#8220;0&#8221;</span>  </span>

- <span style="color: black;">        <span class="attribute" style="color: red;">android:pivotX</span>=<span class="attribute-value" style="color: blue;">&#8220;0&#8221;</span>  </span>

- <span style="color: black;">        <span class="attribute" style="color: red;">android:pivotY</span>=<span class="attribute-value" style="color: blue;">&#8220;0&#8221;</span>  </span>

- <span style="color: black;">        <span class="attribute" style="color: red;">android:toDegrees</span>=<span class="attribute-value" style="color: blue;">&#8220;0&#8221;</span> <span class="tag" style="font-weight: bold; color: #993300;">/></span>  </span>

- <span style="color: black;">  </span>

- <span style="color: black;"><span class="tag" style="font-weight: bold; color: #993300;"></</span><span class="tag-name" style="font-weight: bold; color: #993300;">set</span><span class="tag" style="font-weight: bold; color: #993300;">></span>  </span>





<span style="color: #000000;">新建 进入Activity时的xml</span>
**[html]** [view plain](http://blog.csdn.net/huazai963184709/article/details/10364243#)[copy](http://blog.csdn.net/huazai963184709/article/details/10364243#)[print](http://blog.csdn.net/huazai963184709/article/details/10364243#)[?](http://blog.csdn.net/huazai963184709/article/details/10364243#)
    <div>
    </div>
  </div>
</div>


  - <span style="color: black;"><span class="tag" style="font-weight: bold; color: #993300;"><?</span><span class="tag-name" style="font-weight: bold; color: #993300;">xml</span> <span class="attribute" style="color: red;">version</span>=<span class="attribute-value" style="color: blue;">&#8220;1.0&#8221;</span> <span class="attribute" style="color: red;">encoding</span>=<span class="attribute-value" style="color: blue;">&#8220;utf-8&#8221;</span><span class="tag" style="font-weight: bold; color: #993300;">?></span>  </span>
  
  - <span style="color: black;"><span class="tag" style="font-weight: bold; color: #993300;"><</span><span class="tag-name" style="font-weight: bold; color: #993300;">set</span> <span class="attribute" style="color: red;">xmlns:android</span>=<span class="attribute-value" style="color: blue;">&#8220;http://schemas.android.com/apk/res/android&#8221;</span> <span class="tag" style="font-weight: bold; color: #993300;">></span>  </span>
  
  - <span style="color: black;">  </span>
  
  - <span style="color: black;">    <span class="tag" style="font-weight: bold; color: #993300;"><</span><span class="tag-name" style="font-weight: bold; color: #993300;">rotate</span>  </span>
  
  - <span style="color: black;">        <span class="attribute" style="color: red;">android:duration</span>=<span class="attribute-value" style="color: blue;">&#8220;500&#8221;</span>  </span>
  
  - <span style="color: black;">        <span class="attribute" style="color: red;">android:fromDegrees</span>=<span class="attribute-value" style="color: blue;">&#8220;90&#8221;</span>  </span>
  
  - <span style="color: black;">        <span class="attribute" style="color: red;">android:pivotX</span>=<span class="attribute-value" style="color: blue;">&#8220;100%p&#8221;</span>  </span>
  
  - <span style="color: black;">        <span class="attribute" style="color: red;">android:pivotY</span>=<span class="attribute-value" style="color: blue;">&#8220;100%p&#8221;</span>  </span>
  
  - <span style="color: black;">        <span class="attribute" style="color: red;">android:toDegrees</span>=<span class="attribute-value" style="color: blue;">&#8220;0&#8221;</span> <span class="tag" style="font-weight: bold; color: #993300;">/></span>  </span>
  
  - <span style="color: black;">  </span>
  
  - <span style="color: black;"><span class="tag" style="font-weight: bold; color: #993300;"></</span><span class="tag-name" style="font-weight: bold; color: #993300;">set</span><span class="tag" style="font-weight: bold; color: #993300;">></span>  </span>
<span style="color: #000000;">最后就是代码调用了</span>
**[html]** [view plain](http://blog.csdn.net/huazai963184709/article/details/10364243#)[copy](http://blog.csdn.net/huazai963184709/article/details/10364243#)[print](http://blog.csdn.net/huazai963184709/article/details/10364243#)[?](http://blog.csdn.net/huazai963184709/article/details/10364243#)
- <span style="color: black;">Intent <span class="attribute" style="color: red;">intent</span> = <span class="attribute-value" style="color: blue;">new</span> Intent(ActivityAnimationDemo.this, activtyanimationdemo2.class);  </span>

- <span style="color: black;">startActivity(intent);  </span>

- <span style="color: black;">overridePendingTransition(R.anim.rotate_left, R.anim.rotate_right);  </span>





解释一下应放入的参数
**[html]** [view plain](http://blog.csdn.net/huazai963184709/article/details/10364243#)[copy](http://blog.csdn.net/huazai963184709/article/details/10364243#)[print](http://blog.csdn.net/huazai963184709/article/details/10364243#)[?](http://blog.csdn.net/huazai963184709/article/details/10364243#)
- <span style="color: black;">overridePendingTransition(进入时的动画,离开时的动画) </span>





&nbsp;





[源码下载](http://download.csdn.net/detail/huazai963184709/6016175)(为了方便,把移动和 旋转动画代码写一块了)

💬 评论