Implementation method of Android startup screen
- 2020-06-15 10:11:14
- OfStack
This article illustrates the implementation method of Android startup screen. Share to everybody for everybody reference. The specific analysis is as follows:
The launch screen is often used in applications to launch a background thread to prepare resources for the main program to run.
To implement the boot screen Android can do this:
Here is the code for the splash. xml layout file:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="fill_parent" android:layout_width="fill_parent" android:orientation="vertical">
<ImageView android:layout_height="fill_parent" android:layout_width="fill_parent" android:scaleType="fitCenter" android:src="@drawable/splash"></ImageView>
</LinearLayout>
Put 1 ImageView load launch screen image
SplashActivity is launched as the main view:
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.splash);
Handler x = new Handler();
x.postDelayed(new splashhandler(), 2000);
}
class splashhandler implements Runnable{
public void run() {
startActivity(new Intent(getApplication(),MainActivity.class));
SplashActivity.this.finish();
}
}
I hope this article has been helpful for your Android programming.