实现效果图:
(1)布局界面很简单,就一个背景图片 activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="bottom"
android:background="@drawable/splas">
</LinearLayout>
(2)主界面添加一个动画 MainActivity
public class SplashActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
final View view = View.inflate(this, R.layout.splash, null);
setContentView(view);
//渐变展示启动屏 0.5f表示半透明 1.0f表示不透明
AlphaAnimation aa = new AlphaAnimation(0.1f,1.0f);
aa.setDuration(5000);
view.startAnimation(aa);
aa.setAnimationListener(new Animation.AnimationListener()
{
@Override
public void onAnimationEnd(Animation arg0) {
redirectTo();
}
@Override
public void onAnimationRepeat(Animation animation) {}
@Override
public void onAnimationStart(Animation animation) {}
});
}
/**
* 跳转到...
*/
private void redirectTo(){
Intent intent = new Intent(this, MyActivity.class);
startActivity(intent);
finish();
}
}