I have application with white color status bar and navigation bar. I have define a Splash theme like this.
<style name="Theme.MySplash" parent="Theme.SplashScreen">
<item name="windowSplashScreenBackground">#00f</item>
<item name="windowSplashScreenAnimatedIcon">@drawable/ic_baseline_play_arrow_24</item>
<item name="windowSplashScreenAnimationDuration">200</item>
<item name="postSplashScreenTheme">@style/Theme.AppTheme</item>
</style>
<style name="Theme.AppTheme" parent="Theme.MaterialComponents.DayNight.NoActionBar">
<item name="android:statusBarColor">#fff</item>
<item name="android:navigationBarColor">#fff</item>
</style>
MainActivity
class MainActivity : AppCompatActivity() {
var keepSplashScreen = true
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
val splashScreen = installSplashScreen()
splashScreen.setOnExitAnimationListener { splashScreenProvider ->
val fadeAnim = ObjectAnimator.ofFloat(
splashScreenProvider.view, View.ALPHA, 1f, 0f
)
fadeAnim.duration = 4000L
fadeAnim.interpolator = AccelerateInterpolator()
fadeAnim.doOnEnd { splashScreenProvider.remove() }
fadeAnim.start()
}
splashScreen.setKeepVisibleCondition { keepSplashScreen }
setContentView(R.layout.activity_main)
Handler(Looper.getMainLooper()).postDelayed({
keepSplashScreen = false
}, 3000)
}
}
SplashTheme
working well on device Android 12 (Pixel 4XL) but on Android 8 (Xiomi A2), the SplashTheme
won't display full screen when it exist.
From this video, when SplashScreen
start exist (fade animation), the white status bar and navigation bar is display (on Android 12, SplashScreen
always fullscreen while exist).
How can I make the SplashScreen
always fullscreen on Android < 12?
CodePudding user response:
I think the problem maybe you do not use the compact library. If you’re not using the support library, your splash screen will exactly have the same old look in lower versions as you had before.
implementation 'androidx.core:core-splashscreen:1.0.0-alpha01'
the SplashScreen actually use a frame layout that contains a image view
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="false">
<ImageView
android:id="@ id/splashscreen_icon_view"
android:layout_width="?attr/splashScreenIconSize"
android:layout_height="?attr/splashScreenIconSize"
android:layout_gravity="center"/>
</FrameLayout>
CodePudding user response:
Try this:
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
Write it inside your onCreate
Method. For more, Read this.