Displaying logo for few seconds at application start

后端 未结 7 1264
粉色の甜心
粉色の甜心 2021-02-08 07:13

I want to display a logo for few seconds before application starts and menu is visible. I want also to use some when it disappears. Should I create a new activity? Can I set it

7条回答
  •  情书的邮戳
    2021-02-08 07:42

    define a layout for the splash screen which will contain your logo , and then , add this code to your activity :

    public void onCreate(Bundle savedInstanceState){
        super.onCreate(savedInstanceState);
        setContentView(R.layout.splash);
        //display the logo during 5 seconds,
        new CountDownTimer(5000,1000){
            @Override
            public void onTick(long millisUntilFinished){} 
    
            @Override
            public void onFinish(){
                   //set the new Content of your activity
                   YourActivity.this.setContentView(R.layout.main);
            }
       }.start();
    }
    

提交回复
热议问题