Android Splash Screen before black screen

后端 未结 2 1793
一整个雨季
一整个雨季 2021-01-14 19:15

I would like to display a splash screen while everything is initializing in the onCreate() method, yet components that I need to draw things to the screen are also initializ

相关标签:
2条回答
  • 2021-01-14 19:44

    //avoid time consuming work in UI thread but if that is related to UI itself then do as below

    @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
    
    
                setContentView(R.layout.first_splash_lauoy);
    
                new Handler().postDelayed(new Runnable() {
    
                    public void run() {
                      //Your time consuming work 
                      //with spiiner(if needed) & setContentView(<finalView>)
                      }, 1000);
            }
    
        }
    
    0 讨论(0)
  • Create a XML layout for this splash screen and set it as content view right after your super.onCreate():

    super.onCreate(savedInstanceState);
    setContentView (R.layout.splash_screen);
    

    That should be enough. It would display this splash screen until your setContentView(renderView) is called.

    0 讨论(0)
提交回复
热议问题