This article describes the implementation method of Android startup screen. Share it for your reference. The specific analysis is as follows:
In applications, the startup screen is often used, and a background thread will be started to prepare resources for the main program.
To implement the splash screen on Android, you can do this:
This is the code for the layout file:
Copy the codeThe code is as follows:
<LinearLayout
xmlns:andro
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>
xmlns:andro
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 an ImageView to load the startup screen image
SplashActivity is started as the main view:
Copy the codeThe code is as follows:
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
(savedInstanceState);
setContentView();
Handler x = new Handler();
(new splashhandler(), 2000);
}
class splashhandler implements Runnable{
public void run() {
startActivity(new Intent(getApplication(),));
();
}
}
@Override
public void onCreate(Bundle savedInstanceState) {
(savedInstanceState);
setContentView();
Handler x = new Handler();
(new splashhandler(), 2000);
}
class splashhandler implements Runnable{
public void run() {
startActivity(new Intent(getApplication(),));
();
}
}
I hope this article will be helpful to everyone's Android programming design.