Splash的几种运用

package youbanwang.co.cc;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;

public class Splash extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState)
{
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.splash);

new Handler().postDelayed(new Runnable()
{

@Override
public void run()
{
// TODO Auto-generated method stub
Intent it = new Intent(Splash.this, Youban1Activity.class);
startActivity(it);
finish();
}
}, 2000);
}

}


------------------自动展示图片SPLASH
package tangshi.co.cc;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.widget.ImageView;

public class Splash extends Activity {
private ImageView mImageView;
private Handler mHandler;
private final int SPLASH1 = 0;
private final int SPLASH2 = 1;
private final int SPLASH3 = 2;
private final int TURNTOLOGIN = 3;

@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.splash);
mImageView = (ImageView) findViewById(R.id.imageView1);
mImageView.setImageResource(R.drawable.icon1);
mHandler = new Handler() {
@Override
public void handleMessage(Message msg) {
// TODO Auto-generated method stub
super.handleMessage(msg);
switch (msg.what) {
case SPLASH1:
mImageView.setImageResource(R.drawable.icon1);
break;
case SPLASH2:
mImageView.setImageResource(R.drawable.icon2);
break;
case SPLASH3:
mImageView.setImageResource(R.drawable.icon3);
break;
case TURNTOLOGIN:
mImageView.setImageResource(R.drawable.icon4);
break;
default:

break;
}

};

};
new Thread() {
public void run() {
try {
sleep(1000);
mHandler.sendEmptyMessageDelayed(SPLASH1, 0);
sleep(1000);
mHandler.sendEmptyMessageDelayed(SPLASH2, 0);
Thread.sleep(1000);
mHandler.sendEmptyMessageDelayed(SPLASH3, 0);
sleep(2000);
mHandler.sendEmptyMessageDelayed(TURNTOLOGIN, 0);

} catch (Exception e) {
// TODO: handle exception
} finally {
Intent intent = new Intent(Splash.this,
HahamxActivity.class);
startActivity(intent);
finish();
}

};
}.start();
}
}

---------Splash animation
package gongzibai.co.cc;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.ImageView;
import android.widget.TextView;

public class Splash extends Activity {
private ImageView mImageView;
private TextView mTextView;

Animation animation;

@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.splash1);
mImageView = (ImageView) findViewById(R.id.imageView1);
mTextView=(TextView)findViewById(R.id.textView1);

Animation mAnimation = AnimationUtils.loadAnimation(this,
R.anim.scaleanimation);
mImageView.startAnimation(mAnimation);
mTextView.startAnimation(mAnimation);

new Handler().postDelayed(new Runnable() {

@Override
public void run() {
// TODO Auto-generated method stub

Intent it = new Intent(Splash.this, RandomActivity.class);
startActivity(it);
finish();
}
}, 2000);
}

}

---------anim
<?xml version="1.0" encoding="UTF-8"?>
<set android:shareInterpolator="false" xmlns:android="http://schemas.android.com/apk/res/android">

<alpha

android:fromAlpha="0.0"
android:toAlpha="1.0"
android:duration="3000"
></alpha>


</set>


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值