安卓初始画面去黑色背景

安卓开发每次打开初始界面都会出现讨厌的黑色背景或白色背景,并且出现1-2s的延迟,现在发现一种新的方式可以迅速展示初始页面。

1.将activity的theme主题背景改为初始背景(value中的style)

2.在AndroidManifest中修改Activity的Theme

 

3.在activity的onCreate中引用和处理

  @Override
    public void onCreate(final Bundle icicle) {
        super.onCreate(icicle);
        getWindow().setFormat(PixelFormat.RGBA_8888);
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_DITHER);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
            Window window = getWindow();
            // Translucent status bar
            window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
            // Translucent navigation bar
            window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
        }
        setContentView(R.layout.activity_init);



        new Handler().postDelayed(new Runnable() {
            public void run() {
                /* Create an Intent that will start the Main WordPress Activity. */
              /*  Intent mainIntent = new Intent(splashScreen.this, wpAndroid.class);
                splashScreen.this.startActivity(mainIntent);
                splashScreen.this.finish();*/
                Intent intent = new Intent(InitActivity.this, MainActivity.class);
                ActivityUtil.getInstance().StartActivityWith(InitActivity.this, intent);
                finish();
            }
        }, 2000); //2900 for release

    }


你可能感兴趣的:(Android)