Animation的学问

来源:互联网 发布:java实现邮件收发 编辑:程序博客网 时间:2024/05/24 06:38


动画播放相信大家一定不会陌生,不过动画的大杀器很多人可能没用过,这里提供三种较为简便的方式开展动画的制作,近期在写的程序总结出来打个点

动画加载的三种方式


第一种

注意AnimationUtils的使用,这里 少了很多麻烦的事情,代码的具体的类需要指定的东西过多,这里写好xml加载进来,让动画尽情的转起来

private void showHead(View head, View content) {    head.startAnimation(AnimationUtils.loadAnimation(this, R.anim.slide_out_top));    content.startAnimation(AnimationUtils.loadAnimation(this, R.anim.content_down));    content.setPadding(0, 200, 0, 0);    }
<set xmlns:android="http://schemas.android.com/apk/res/android"    android:interpolator="@android:anim/decelerate_interpolator"    >    <translate        android:duration="5000"        android:fromYDelta="-200"        android:toYDelta="0" /></set>

<set xmlns:android="http://schemas.android.com/apk/res/android"    android:interpolator="@android:anim/decelerate_interpolator"    >    <translate        android:duration="5000"        android:fromYDelta="-200"        android:toYDelta="0" /></set>


利用系统的AnimationUtils进行动画的播放,这里面可以省掉自己书写很多的参数也算是比较方便


第二种方式:.

int version =  Integer.valueOf(android.os.Build.VERSION.SDK);if(version > 5 ){overridePendingTransition(R.anim.zoomin, R.anim.zoomout);}
注意最关键的这个方法的注释,和两个参数的作用,这个作用很大的,对于outside的Activity也是有作用的
void android.app.Activity.overridePendingTransition(int enterAnim, int exitAnim)Call immediately after one of the flavors of startActivity(Intent) or finish to specify an explicit transition animation to perform next. As of android.os.Build.VERSION_CODES.JELLY_BEAN an alternative to using this with starting activities is to supply the desired animation information through a ActivityOptions bundle to or a related function. This allows you to specify a custom animation even when starting an activity from outside the context of the current top activity.Parameters:enterAnim A resource ID of the animation resource to use for the incoming activity. Use 0 for no animation.exitAnim A resource ID of the animation resource to use for the outgoing activity. Use 0 for no animation.


第三种方式

传统的方式  五种动画 直接new出来,然后使用AnimationSet或者单独使用某一个,然后view执行动画


动画的执行方式不止这几种关键是用的好,用的到位才行


简单总结,随后会更新

0 0
原创粉丝点击