第一种方法
直接放进MainActivity中就行了
ImageView logoImage = (ImageView) this.findViewById(R.id.img);
AlphaAnimation alphaAnimation = new AlphaAnimation(0.1f, 1.0f);
alphaAnimation.setDuration(3000);
logoImage.startAnimation(alphaAnimation);
alphaAnimation.setAnimationListener(new AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationRepeat(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
Intent intent = new Intent();
intent.setClass(TongxunluActivity.this, LoginActivity.class);
startActivity(intent);
finish();
}
});```
>第二种方法
###新建一个SpinshDemo让此Activity跳转到主Activity中去(不要忘记注册新建的Activity)
public class SpinshDemo extends Activity {
private Thread newThread;
private long sleeptime = 3000;
private boolean ispause = false;
private boolean isSpinshActivity = true;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// 设置全屏
setondraweble();
setContentView(R.layout.spinshmain);
// 设置睡眠时间
setSpinshTime();
}
private void setSpinshTime() {
newThread = new Thread() {
@Override
public void run() {
super.run();
long ms = 0;
try {
while (isSpinshActivity && ms < sleeptime) {
sleep(100);
// 如果不再后台 那我们肯定是 增加睡眠时间的
if (!ispause) {
ms += 100;
}
}
startActivity(new Intent(SpinshDemo.this,
SpinshDemoActivity.class));
Log.e("aaaaaaaaaaa", "enen跳转了");
} catch (InterruptedException e) {
e.printStackTrace();
} finally {
finish();
}
;
}
};
newThread.start();
}
private void setondraweble() {
// 设置无标题
requestWindowFeature(Window.FEATURE_NO_TITLE);
// 设置全屏参数
int flag = WindowManager.LayoutParams.FLAG_FULLSCREEN;
// 获得window
Window myWindow = this.getWindow();
// 输出
myWindow.setFlags(flag, flag);
}
// 暂停界面
@Override
protected void onPause() {
super.onPause();
ispause = true;
}
// 又回到这个界面
@Override
protected void onResume() {
super.onResume();
ispause = false;
}
}