自定义闪屏

在AndroidManifest声明一个activity并设置为启动activity:
QQ图片20190710112948.png

然后实现闪屏activity,显示闪屏图片,并延迟相应时间,结束显示再调用显示主activity即可。

package com.tyrty.xkfb.gfgf;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.CountDownTimer;
import android.view.Window;

public class SplashActivity extends Activity {
    
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        getWindow().setFlags(0x400, 0x400);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.splash);
        new CountDownTimer(0xbb8, 0x64) {
            @Override
            public void onTick(long millisUntilFinished) {

            }
            @Override
            public void onFinish() {
                Intent intent = new Intent();
                intent.setClass(SplashActivity.this, MainActivity.class);
                startActivity(intent);
                finish();
            }
        }.start();
    }
}

你可能感兴趣的:(自定义闪屏)