微信开门动画的实现

来源:互联网 发布:js compare函数 编辑:程序博客网 时间:2024/04/19 22:34

当前很多应用首次安装启动后会出现门一样的动画,下面我们就看看他的实现

其主要实现是动画的实现

/**导航过后的动画效果界面*/public class WhatsnewAnimationA extends Activity {private ImageView img_left, img_right;@Overrideprotected void onCreate(Bundle savedInstanceState) {// TODO Auto-generated method stubsuper.onCreate(savedInstanceState);setContentView(R.layout.whatnew_animation);img_left = (ImageView) findViewById(R.id.doorpage_left);img_right = (ImageView) findViewById(R.id.doorpage_right);//创建一个AnimationSet对象AnimationSet animLeft = new AnimationSet(true);TranslateAnimation transLeft = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0f, Animation.RELATIVE_TO_SELF,-1f, Animation.RELATIVE_TO_SELF, 0f,Animation.RELATIVE_TO_SELF, 0f);//设置动画效果持续的时间transLeft.setDuration(2000);//将anim对象添加到AnimationSet对象中animLeft.addAnimation(transLeft);animLeft.setFillAfter(true);img_left.startAnimation(transLeft);transLeft.startNow();//创建一个AnimationSet对象AnimationSet animRight = new AnimationSet(true);TranslateAnimation transRight = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0f, Animation.RELATIVE_TO_SELF,1f, Animation.RELATIVE_TO_SELF, 0f,Animation.RELATIVE_TO_SELF, 0f);//设置动画效果持续的时间transRight.setDuration(2000);//将anim对象添加到AnimationSet对象中animRight.addAnimation(transRight);animRight.setFillAfter(true);img_right.startAnimation(transRight);transRight.startNow();new Handler().postDelayed(new Runnable() {@Overridepublic void run() {// TODO Auto-generated method stubIntent intent = new Intent(WhatsnewAnimationA.this, FirstPageA.class);startActivity(intent);WhatsnewAnimationA.this.finish();}}, 1000);}}


开门activity的whatnew_animation.xml

<?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"    android:layout_width="fill_parent"    android:layout_height="fill_parent">    <ImageView         android:id="@+id/doorpage_left"        android:scaleType="fitXY"        android:layout_width="fill_parent"        android:layout_height="fill_parent"android:src="@drawable/doorpage_left"/>    <ImageView         android:id="@+id/doorpage_right"        android:scaleType="fitXY"        android:layout_width="fill_parent"        android:layout_height="fill_parent"        android:src="@drawable/doorpage_right"/>    </RelativeLayout>


 

0 0