The meaning of the start-up interface is to make the background processing time-consuming complex work, when the work is done, you can enter the main interface. Using a single image as the starting background is a better experience than letting the user wait for the layout to load.
First, you need to create a simple layout:
<?XML version= "1.0" encoding= "Utf-8"?><LinearLayoutxmlns:android= "Http://schemas.android.com/apk/res/android"Android:layout_width= "Match_parent"Android:layout_height= "Match_parent"Android:background= "@drawable/launch"android:orientation= "vertical"></LinearLayout>
Here I will directly set the background of the entire layout as a picture, so that it can adapt to the size of the screen.
Then, create a launchactivity, register it in Androidmanifest, and let it start first:
Public classLaunchactivityextendsActivity {@Overrideprotected voidonCreate (Bundle savedinstancestate) {Super. OnCreate (savedinstancestate); //Load Startup pictureSetcontentview (R.layout.activity_launch); //background processing time-consuming tasks NewThread (NewRunnable () {@Override Public voidrun () {//time consuming tasks, such as loading network dataRunonuithread (NewRunnable () {@Override Public voidrun () {//Jump to MainactivityIntent Intent =NewIntent (launchactivity. This, Mainactivity.class); StartActivity (Intent); //End the current ActivityLaunchactivity. This. Finish (); } }); }}). Start (); }}
This way, once the background task has finished processing, it will automatically go to the main interface of the software.
Of course, there is also a timer to start the main interface, usually for ad serving.
Public classLaunchactivityextendsActivity {@Overrideprotected voidonCreate (Bundle savedinstancestate) {Super. OnCreate (savedinstancestate); //Loading the Startup interfaceSetcontentview (R.layout.activity_launch); Integer Time= 2000;//set the wait time in millisecondsHandler Handler =NewHandler (); //when the timing is over, jump to the main screenHandler.postdelayed (NewRunnable () {@Override Public voidrun () {startactivity (NewIntent (launchactivity. This, Mainactivity.class)); Launchactivity. This. Finish (); }}, time); }}
Android Settings Launcher screen