How do Make a Splash Screen

When you open any android app you will get by default a some what black screen with the title and icon of the app on top, you can change that by using a style/theme.

First, create a style.xml in values folder and add a style to it.

<style name="splashScreenTheme" parent="@android:style/Theme.DeviceDefault.Light.NoActionBar">

    <item name="android:windowBackground">@drawable/splash_screen</item>

</style>

Instead of using @android:style/Theme.DeviceDefault.Light.NoActionBar you can use any other theme as a parent.

Second, in your app Manifest.xml add android:theme="@style/splashScreenTheme" to your main activity.

<activity

        android:name="MainActivity"

        android:label="@string/app_name"

        android:theme="@style/splashScreenTheme" >

Third, Update your theme in your onCreate() launch activity.

protected void onCreate(Bundle savedInstanceState) {

    // Make sure this is before calling super.onCreate

    setTheme(R.style.mainAppTheme);

    super.onCreate(savedInstanceState);

}

Postingan populer dari blog ini

How to change an Android app's name?