I have an app where I used the dark theme. I have also added a splash screen where I have added an animation. The background of the SplashActivity is white. When I first start the app, I get a dark screen and then the splash screen is displayed. How to get rid of that dark screen and see directly the splash screen? Thanks
Its related to Cold Start. It happens when your app starts for the first time as explained in the android documentation. However to deal with it I prefer the solution of having background drawable and set it to app theme if your Splash screen is static but in your case as you are using animations you need to use mixture of both techniques i.e. setting the splash screen theme as drawable which is loaded during cold start and later on when it finishes you render your animated stuff.
Related
I know that there are 2 common methods of implementing splash screens:
Using activity and Timers
Using a Launcher Theme
Using a Launcher theme is the preferred way because I need splash while cold start.
But suppose I need to implement a splash screen with animated logo, text and background.
Is it possible using the Launcher Theme to create animated splash screen or animations is quite not possible in this method and I will have to create separate activity for my splash screen.
Please help me)
You could use Android's SplashScreenApi to launch your app.
This includes an into-app motion at launch, a splash screen showing your app icon, and a transition to your app itself. This provides a seamless transition into our app -
https://developer.android.com/guide/topics/ui/splash-screen
I've read every questions on this site about how to put a splash screen on app start-up to avoid the white screen problem. However the white screen still pops-up when the app has been in the background for a while. Is there anyway to either make it transparent or redirect the app to the splash screen if the app has been in the background for a while?
To get rid of the white screen which is because of android's cold start, and appears when the app loads to memory, you can add the following style item to your AppTheme.
<item name="android:windowDisablePreview">true</item>
I'm trying to use AnimatedVectorDrawable as a splash animation placed in the window background. I use the official example given in https://developer.android.com/reference/android/graphics/drawable/AnimatedVectorDrawable.html. It appears but doesn't animate.
Are animations in a Window background possible at all?
The first screen that you see when opening an app for the first time (cold start) is a screen placeholder create by the WindowManager. It creates the placeholder by getting resources that you set on your theme, like the window background and status bar color. To start the animation of your window background you have to call its start() method, but the WindowManager is a system service that you have little or no control over. So on this phase of application initialisation, unless there is some obscure way to control the WindowManager in the Application.onCreate() method, it is not possible to animate the vector background.
I opened from cold start a lot of my apps including Google ones and not a single one seems to implement animations on the cold start phase (like the docs of Material Design imply possible). A very few make animations after the cold start at the onCreate of the main activity.
If it's not a problem start the animation after he cold start, like in the case of moving the logo to the top of the screen, you can:
Set a theme with attribute android:windowBackground to your static drawable at your launch activity in AndroidManifest.xml
Before call super.onCreate() in your Activity, change the theme for your default theme.
Set a content view with a ImageView of your AnimatedVectorDrawable at the same position of your static window background vector.
Call start() method of your AnimatedVectorDrawable.
Here is an AndroidDeveloper's post explaining in details how to deal with application themes for launch screens
I have an activity with bark background launched as singleInstanse, and when it's starts the first time it has a shot white flash (white background shown) before showing its content. How can I prevent that? Or may be it is possible set up activity's default background color at start? Thanks.
This is due to what is called the preview window during app launching.
A very clear explanation of the issue and how to get around it is given by Cyril Mottier in android-app-launching-made-gorgeous
your app theme should have background color... thid color will replace the dark screen.
I have a problem of white screen when I relaunch background app.
I click home button and then I click on app logo, my application resume and sometimes I have a white screen.
Do you know what's happening please?
This is the time that your application takes starting, before first activity is displayed.
If you extended the application class, you can look at the onCreate method, if there is much code here.
You can minimize the effects, setting the default window background to a color or drawable in a theme:
<item name="android:windowBackground">#color/mycolor</item>