activity_splash.xml
具体布局内容自己定义
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:orientation="horizontal" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="com.administrator.taolvyou.SplashActivity"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Hello World!" /> </LinearLayout>
Java代码
SplashActivity.java
package com.administrator.taolvyou; import android.content.Intent; import android.os.Handler; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; public class SplashActivity extends AppCompatActivity { protected Handler mHandler = new Handler(); @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_splash); mHandler.postDelayed(new Runnable() { @Override public void run() { startActivity(new Intent(SplashActivity.this,MainActivity.class)); } },2000); } }