看到这个我的闪屏动画,一个接一个
我的布局和一些视图
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/root_layout"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<ImageView
android:id="@+id/img_bg"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scaleType="fitXY"
android:src="@drawable/splash_background" />
<ImageView
android:id="@+id/imageCircle"
android:layout_width="150dp"
android:layout_height="150dp"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginTop="50dp"
android:src="@drawable/circle_bg_1" />
<ImageView
android:id="@+id/imageSale"
android:layout_width="150dp"
android:layout_height="150dp"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_marginTop="50dp"
android:src="@drawable/avsave_text" />
</RelativeLayout>
res/anim/translate_from_left_to_right.xml 中的translate_from_left_to_right 动画
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:fillAfter="true"
android:interpolator="@android:anim/decelerate_interpolator" >
<translate
android:duration="1000"
android:fromXDelta="-100%"
android:toXDelta="50%" />
res/anim/translate_from_right_to_left.xml 中的translate_from_right_to_left 动画
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:fillAfter="true"
android:interpolator="@android:anim/decelerate_interpolator" >
<translate
android:duration="1000"
android:fromXDelta="100%"
android:toXDelta="-50%" />
res/anim/zoom_out.xml 中的zoom_out 动画
<?xml version="1.0" encoding="utf-8"?>
<scale xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="2000"
android:fromXScale="1.5"
android:fromYScale="1.5"
android:pivotX="50%"
android:pivotY="50%"
android:toXScale="1"
android:toYScale="1" >
</scale>
最后是我的 SplashActivity.java 文件
package com.av.stores;
imprt android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.Animation.AnimationListener;
import android.view.animation.AnimationUtils;
import android.widget.ImageView;
public class SplashActivity extends Activity {
private ImageView imgCircle, imgSale;
private ImageView imgSplashBg;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.splash_screen);
}
@Override
protected void onStart() {
imgCircle = (ImageView) findViewById(R.id.imageCircle);
imgSale = (ImageView) findViewById(R.id.imageSale);
imgSale.setVisibility(View.INVISIBLE);
imgCircle.setVisibility(View.INVISIBLE);
imgSplashBg = (ImageView) findViewById(R.id.img_bg);
Animation zoomAnim = AnimationUtils.loadAnimation(this, R.anim.zoom_out);
final Animation animLeftToRight = AnimationUtils.loadAnimation(this,
R.anim.translate_left_to_right);
final Animation animRightToLeft = AnimationUtils.loadAnimation(this,
R.anim.translate_right_to_left);
imgSplashBg.startAnimation(zoomAnim);
zoomAnim.setAnimationListener(new AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
// TODO Auto-generated method stub
}
@Override
public void onAnimationRepeat(Animation animation) {
// TODO Auto-generated method stub
}
@Override
public void onAnimationEnd(Animation animation) {
imgCircle.startAnimation(animLeftToRight);
}
});
animLeftToRight.setAnimationListener(new AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationRepeat(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
imgSale.setVisibility(View.VISIBLE);
imgSale.startAnimation(animRightToLeft);
}
});
animRightToLeft.setAnimationListener(new AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
// TODO Auto-generated method stub
}
@Override
public void onAnimationRepeat(Animation animation) {
// TODO Auto-generated method stub
}
@Override
public void onAnimationEnd(Animation animation) {
new Handler().postDelayed(new Runnable() {
/*
* Showing splash screen with a timer. This will be useful
* when you want to show case your app logo / company
*/
@Override
public void run() {
/*Intent i = new Intent(SplashActivity.this,
MainActivity.class);
startActivity(i);
overridePendingTransition(R.anim.activity_enter,
R.anim.activity_leave);*/
finish();
}
}, 500);
}
});
super.onStart();
}
}