package ui;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.MotionEvent;
import android.view.Window;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.view.animation.Animation.AnimationListener;
import android.view.animation.AnimationSet;
import android.view.animation.RotateAnimation;
import android.view.animation.ScaleAnimation;
import android.widget.LinearLayout;
import android.widget.Toast;
import com.example.play.R;
/**
* 启动页
*
* @author Administrator
*
*/
public class Splash extends Activity {
private LinearLayout ll;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.activity_splash);
init();
// 设置动画
setAnimation();
}
private void setAnimation() {
AnimationSet set = new AnimationSet(false);
/**
* 平移动画
*/
// TranslateAnimation ta=new TranslateAnimation(fromXDelta, toXDelta,
// fromYDelta, toYDelta)
/**
* 旋转动画
*/
RotateAnimation rt = new RotateAnimation(0, 360,
Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF,
0.5f);
rt.setDuration(2000);
rt.setFillAfter(true);
/**
* 透明度的变化
*/
AlphaAnimation ap = new AlphaAnimation(0.2f, 1);
ap.setDuration(3000);
ap.setFillAfter(true);
/**
* 缩放动画
*/
ScaleAnimation sc = new ScaleAnimation(0, 1, 0, 1,
Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF,
0.5f);
sc.setDuration(3000);
ap.setFillAfter(true);
set.addAnimation(ap);
set.addAnimation(rt);
set.addAnimation(sc);
set.setAnimationListener(new AnimationListener() {
@Override
public void onAnimationStart(Animation arg0) {
}
@Override
public void onAnimationRepeat(Animation arg0) {
}
@Override
public void onAnimationEnd(Animation arg0) {
startActivity(new Intent().setClass(Splash.this, Welcome.class));
}
});
ll.startAnimation(set);
}
/**
* 下面的没用 只是写着完的
*/
@Override
public boolean onTouchEvent(MotionEvent event) {
// Log.e("ssssssssssssssssss", event);
if (event.getAction() == MotionEvent.ACTION_DOWN) {
Toast.makeText(Splash.this, "用户向下移动了", 0).show();
}
if (event.getAction() == MotionEvent.ACTION_CANCEL) {
Toast.makeText(Splash.this, MotionEvent.ACTION_CANCEL + "", 0)
.show();
}
if (event.getAction() == MotionEvent.ACTION_MOVE) {
Toast.makeText(Splash.this, MotionEvent.ACTION_MOVE + "", 0).show();
}
return false;
}
private void init() {
ll = (LinearLayout) findViewById(R.id.ll);
}
}
xml文件
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/ll"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/dierzhang"
android:orientation="horizontal" >
</LinearLayout>