Android 欢迎页实现
1.界面展示
2.界面布局
<?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:layout_width="match_parent"
android:layout_height="match_parent"
android:theme="@style/Theme.AppCompat.NoActionBar"
tools:context=".MainActivity">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="fitXY"
android:src="@mipmap/bg002"/>
</LinearLayout>
3.功能实现
package com.example.day_06;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Window;
import android.view.WindowManager;
import java.util.Timer;
import java.util.TimerTask;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
getSupportActionBar().hide();//去除标题栏
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);//实现全屏
startMainActivity();
}
private void startMainActivity(){
TimerTask delayTask = new TimerTask() {
@Override
public void run() {
Intent mainIntent = new Intent(MainActivity.this,MainActivity2.class);
startActivity(mainIntent);
MainActivity.this.finish();
}
};
Timer timer = new Timer();
timer.schedule(delayTask,3000);//延时两秒执行 run 里面的操作
}
}
4.源代码下载
点击下载