5

How do i show full splash screen with background image & also i want to show status bar background what activity has.

Following splash activity has full image it will might be change in future, right now i did iugaad to show that status bar background but whenever i am changing my image status bar background should that image.

Splash Screen

1 Answers1

15

You need to do following steps,

v21/styles.xml

<style name="AppTheme.NoActionBar" parent="Theme.AppCompat.Light.NoActionBar">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorStatusBarColor</item>
    <item name="colorAccent">@color/colorAccent</item>
    <item name="windowNoTitle">true</item>
    <item name="windowActionBar">false</item>

    <!--Required Api 21 above-->
        <item name="android:windowDrawsSystemBarBackgrounds">true</item>
        <item name="android:statusBarColor">@android:color/transparent</item>

</style>

Note: Add above style without v21 code in styles.xml

Apply that style in AndroidManifest.xml as `android:theme

 android:theme="@style/AppTheme.NoActionBar">

Now simply go to your activity & add following line of code in onCreate method,

private Window mWindow;

@Override
protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_splash);

        mWindow = getWindow();
        mWindow.getDecorView().setSystemUiVisibility(
                View.SYSTEM_UI_FLAG_LAYOUT_STABLE
                        | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
}

Run now & output will like this,

enter image description here

Mukesh Lokare
  • 2,159
  • 26
  • 38
  • 1
    It works ! You articulated it very transparent ;) thumbs up for ally. –  Sep 01 '17 at 15:10
  • 1
    Fantastic! One note, may want to include the required 'import android.view.Window/import android.view.View;' lines (I'm coming from react-native so am not familiar with Java coding!) – Chris Sherriff Jul 19 '19 at 12:21