Skip to content
webtoapkfree

How do I add a splash screen to a WebView app?

Add a WebView splash screen with the AndroidX SplashScreen API, keep it up until the first page commits, and cap the wait for slow networks.

GuidesNookesh Karri

Light cover card with the title 'How do I add a splash screen to a WebView app?' in dark text and a green accent bar

To add a WebView splash screen, use the AndroidX core-splashscreen library: give your WebView Activity a splash theme, call installSplashScreen() before super.onCreate(), and hold the splash with setKeepOnScreenCondition until the first page is ready to draw. Add a short timeout so a slow network never leaves people staring at your logo. Skip the old separate “SplashActivity” pattern.

Why a WebView app needs a different splash approach

A WebView app has two loading phases: Android starting your Activity, and the WebView fetching your site. Android’s splash screen guide says that starting in Android 12, apps launch with “a splash screen showing your app icon, and a transition to your app itself.”

That system splash covers the first phase only. The guide also says “the splash screen is dismissed as soon as your app draws its first frame.” An empty WebView is a frame. So the splash vanishes, and users get the blank white flash covered in why a WebView shows a white screen while the page is still loading.

Why the old splash Activity breaks on Android 12

The classic tutorial pattern is a SplashActivity with a timer that then starts the WebView Activity. On new phones this produces two splash screens. Google’s migration guide states that a dedicated splash Activity on Android 12 or later “results in duplicate splash screens.”

A timer ignores your page. On fast Wi-Fi it wastes time. On a train it ends before the site arrives.

What you need before you start

You need a WebView Activity that already loads your site, and the AndroidX splash library. The guide lists this dependency:

implementation("androidx.core:core-splashscreen:1.2.0")

The guide says the library “brings the Android 12 splash screen to all devices from API 23.” The guide also requires the icon as a vector drawable. Size it to Android’s specs:

Icon style Canvas Keep the logo inside
No icon background (Theme.SplashScreen) 288×288 dp 192 dp circle
With icon background (Theme.SplashScreen.IconBackground) 240×240 dp 160 dp circle
Optional branded image 200×80 dp n/a

The circle matters because Android masks everything outside it. The launcher icon size guide covers the same safe-zone idea for the home screen icon.

How to add a WebView splash screen, step by step

The setup takes four steps: a theme, a manifest change, the install call, and a keep-on-screen condition tied to the WebView. This is the Kotlin version I ship.

  1. Create a splash theme. Per the migration guide, its parent is Theme.SplashScreen, and it must set postSplashScreenTheme, the theme your Activity switches to after the splash.
<style name="Theme.App.Starting" parent="Theme.SplashScreen">
    <item name="windowSplashScreenBackground">@color/brand_bg</item>
    <item name="windowSplashScreenAnimatedIcon">@drawable/ic_splash</item>
    <item name="postSplashScreenTheme">@style/Theme.App</item>
</style>
  1. Apply it in the manifest. Set android:theme="@style/Theme.App.Starting" on the WebView Activity that has the launcher intent filter.

  2. Install the splash before super.onCreate(). The migration guide says to “call installSplashScreen in the starting activity before calling super.onCreate().”

  3. Hold the splash until the page commits. Use onPageCommitVisible. The WebViewClient reference says it fires when “WebView content left over from previous page navigations will no longer be drawn.” It fires before onPageFinished, which only reports that “a page has finished loading.”

class MainActivity : AppCompatActivity() {
    @Volatile private var ready = false

    override fun onCreate(savedInstanceState: Bundle?) {
        val splash = installSplashScreen()
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)

        splash.setKeepOnScreenCondition { !ready }
        // Never hold the splash on a slow or dead network.
        window.decorView.postDelayed({ ready = true }, TimeUnit.SECONDS.toMillis(3))

        val webView = findViewById<WebView>(R.id.webview)
        webView.webViewClient = object : WebViewClient() {
            override fun onPageCommitVisible(view: WebView, url: String) {
                ready = true
            }
        }
        webView.loadUrl("https://example.com/")
    }
}

The condition only flips one way, so later page loads never bring the splash back. A community WebView splash tutorial needs an extra flag to fix that bug.

How long to keep the splash on screen

Keep the splash only as long as the first paint needs, then hand over to the page. Google’s migration guide is direct: “for network-based loads with indeterminate durations, dismiss the splash screen and show placeholders.”

A WebView loading a live site is exactly that kind of load. My take: the timeout is the most important line in the snippet. Without it, a user on a weak signal sees a frozen logo and assumes the app crashed. With it, they see the WebView’s loading state or your error page.

Keep the condition cheap, too. The SplashScreen reference warns the condition “is evaluated before each request to draw the application, so it needs to be fast.” Reading a boolean is fine. Checking the network inside it is not.

How to check the WebView splash screen works

Test a cold start, because the splash never shows on a hot start. Swipe the app away from recents, then tap the icon.

  • Fast network: the splash fades straight into your page, with no white flash.
  • Airplane mode: the splash leaves after the timeout and your offline page shows. The guide to WebView apps without internet covers that page.
  • Device older than Android 12: the background and icon appear, but an animated icon stays still.

Common WebView splash screen problems

Most splash bugs come from the theme or the timing, not the WebView itself.

  • Two splash screens on Android 12+. You still have a SplashActivity. Delete it and move the launcher intent filter to the WebView Activity.
  • App crashes with a theme error after the splash. postSplashScreenTheme is missing, so the Activity keeps a splash theme that lacks your app bar attributes.
  • Animated icon doesn’t move on older phones. That’s expected. The reference says “on API < 31, windowSplashScreenAnimatedIcon cannot be animated.”
  • Logo is clipped. The drawing goes past the 192 dp or 160 dp circle.
  • Splash never closes. The WebView failed to load and you have no timeout.

Limits of this approach

The SplashScreen library fixes launch. It does nothing for a slow site. If your homepage takes several seconds to render, a longer splash just hides that. The fix is a lighter first page, which the post on whether WebView apps are slower than native goes into.

Old devices have one more gap. The reference notes that on API 21 and 22 “the icon isn’t displayed until the application starts.” In practice that barely matters, since the library’s guide targets API 23 and up.

If you build with a no-code tool, check what splash it already generates. Adding your own on top brings back the duplicate. The website to APK guide walks through the full build.

FAQ

Do I need a separate splash Activity for a WebView app?

No. On Android 12 and later a dedicated splash Activity shows up after the system splash, so users see two splash screens. Use the AndroidX SplashScreen library in your WebView Activity instead.

Why does my WebView app show a white screen before the page appears?

The system splash closes as soon as the app draws its first frame, and an empty WebView counts as a frame. Keep the splash on screen with setKeepOnScreenCondition until the first page is ready to draw.

What size should the splash screen icon be?

Android asks for 288×288 dp with the icon inside a 192 dp circle, or 240×240 dp inside a 160 dp circle if you use an icon background. The icon must be a vector drawable.

Does the splash screen show every time the app opens?

No. It shows on a cold start and a warm start. Android says the splash screen never shows during a hot start, when the Activity is still in memory.

Sources