You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Android跳转新Activity后Splash Screen仍显示的问题求助

Fixing Persistent Splash Screen Covering New Activity

Hey there! Let's work through why your splash screen is sticking around and covering your new Activity—this is a super common pitfall for Android beginners, so don't worry, we'll get it sorted. Since you followed the "Splash Screen right way" guide, here are the most likely issues to check:

  • Double-check your Activity themes in AndroidManifest.xml
    It's easy to accidentally apply the splash screen theme to your main Activity by mistake. Open your AndroidManifest.xml and make sure:

    • Your Splash Activity uses the dedicated splash theme (e.g., @style/SplashTheme)
    • Your main Activity uses your app's regular theme (e.g., @style/AppTheme) instead of the splash one.

    Example correct configuration:

    <activity
        android:name=".SplashActivity"
        android:theme="@style/SplashTheme">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    
    <activity
        android:name=".MainActivity"
        android:theme="@style/AppTheme" /> <!-- No splash theme here! -->
    
  • Ensure your Splash Activity calls finish() after navigating
    If you forget to finish the Splash Activity when launching your main Activity, it'll stay in the task stack and its background might still show through. Make sure your Splash Activity's navigation code includes finish():

    Example in Kotlin:

    class SplashActivity : AppCompatActivity() {
        override fun onCreate(savedInstanceState: Bundle?) {
            super.onCreate(savedInstanceState)
            // No need for setContentView—your splash theme handles the background
            Handler(Looper.getMainLooper()).postDelayed({
                val intent = Intent(this, MainActivity::class.java)
                startActivity(intent)
                finish() // Critical: closes the Splash Activity
            }, 1000)
        }
    }
    
  • Verify your splash theme is only for the splash screen
    Your splash theme should only define the windowBackground for the splash screen, and your main app theme should override this with a normal background. Check your styles.xml:

    Splash theme:

    <style name="SplashTheme" parent="Theme.AppCompat.NoActionBar">
        <item name="android:windowBackground">@drawable/your_splash_drawable</item>
    </style>
    

    Main app theme:

    <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
        <item name="android:windowBackground">@color/white</item>
        <!-- Your other theme customizations -->
    </style>
    
  • Clean and rebuild your project
    Sometimes Android Studio's build cache can cause old theme settings to stick around. Go to Build > Clean Project, then Build > Rebuild Project to rule out caching issues.

If none of these fix it, feel free to share your AndroidManifest.xml and styles.xml code snippets—we can dig deeper!

内容的提问来源于stack exchange,提问作者Nguyen Hoang Vu

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.29 07:59:40