2.8 KiB
2.8 KiB
Splash Screen Fix Implementation
Issues Found and Fixed
1. Missing Splash Screen Assets
- Problem: The
launch_background.xmlfiles were referencing non-existent splash screen images - Fix: Updated to use the existing
@mipmap/ic_launcherresource
2. Incorrect Night Mode Theme
- Problem: Night mode theme was using
Theme.Light.NoTitleBarinstead ofTheme.Black.NoTitleBar - Fix: Updated
android/app/src/main/res/values-night/styles.xmlto use proper dark theme
3. Missing Dedicated Splash Activity
- Problem: No dedicated splash screen activity to handle the initial app launch
- Fix: Created
SplashActivity.ktwith proper timing and transition
4. Incomplete Theme Configuration
- Problem: Missing proper theme configuration for splash screen
- Fix: Added
SplashThemeto both light and dark mode styles
Files Created/Modified
New Files:
android/app/src/main/kotlin/com/example/qpay/SplashActivity.kt- Dedicated splash activityandroid/app/src/main/res/layout/activity_splash.xml- Splash screen layoutandroid/app/src/main/res/values/colors.xml- Color definitionsandroid/app/src/main/res/values/strings.xml- String resources
Modified Files:
android/app/src/main/AndroidManifest.xml- Added SplashActivity as launcherandroid/app/src/main/res/values/styles.xml- Added SplashThemeandroid/app/src/main/res/values-night/styles.xml- Fixed dark theme and added SplashThemeandroid/app/src/main/res/drawable/launch_background.xml- Fixed image referenceandroid/app/src/main/res/drawable-v21/launch_background.xml- Fixed image referenceandroid/app/build.gradle.kts- Added AppCompat dependencylib/main.dart- Added proper Flutter initialization
How It Works
- App Launch: When the app starts,
SplashActivityis launched first - Splash Display: Shows the app icon and name for 2 seconds
- Transition: Automatically transitions to
MainActivity(Flutter app) - Theme Support: Properly handles both light and dark mode themes
Testing
The splash screen has been tested with:
- ✅ Debug build compilation
- ✅ Proper resource references
- ✅ Theme compatibility
- ✅ Activity transitions
Usage
The splash screen will now automatically display when the app launches. The implementation:
- Shows for 2 seconds (configurable in
SplashActivity.kt) - Displays the app icon and name
- Supports both light and dark themes
- Transitions smoothly to the main Flutter app
Customization
To customize the splash screen:
- Duration: Modify the delay in
SplashActivity.kt(currently 2000ms) - Logo: Replace
@mipmap/ic_launcherwith your custom image - Colors: Update
@color/splash_backgroundincolors.xml - Layout: Modify
activity_splash.xmlfor different designs