Skip to content

Instantly share code, notes, and snippets.

@trinnguyen
Last active March 18, 2020 14:56
Show Gist options
  • Save trinnguyen/dd24d22bdd3ca887ebca57a1d530cbf7 to your computer and use it in GitHub Desktop.
Save trinnguyen/dd24d22bdd3ca887ebca57a1d530cbf7 to your computer and use it in GitHub Desktop.
Android style for Splash screen with status bar and navigation bar are transparent, API 21+
<style name="AppTheme.Splash">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<item name="android:statusBarColor">@android:color/transparent</item>
<item name="android:navigationBarColor">@android:color/transparent</item>
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
</style>
@trinnguyen
Copy link
Author

Update UI flags on activity:

 View decorView = getWindow().getDecorView();
        decorView.setSystemUiVisibility(
                View.SYSTEM_UI_FLAG_LAYOUT_STABLE
                        | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                        | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION);

@trinnguyen
Copy link
Author

Ensure no android:fitsSystemWindows="true" in Root Layout

Example:

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/frame_root"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:padding="0dp"
    android:background="#ff00ff"
    tools:context="com.trinnguyen.emptysplash.MainActivity">


    <SurfaceView
        android:id="@+id/surface_view"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="#ff0000" />

</FrameLayout>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment