I'm developing a themes chooser feature in my "app manager" app, and I've succeeded setting the theme dynamically for each of the activities.
AGAIN : this is not about setting the theme for the activities. This actually works fine for me.
The acitivties are showing the correct theme, but the application itself, when launching the app, is showing the wrong one, no matter what I do.
This is a problem because when the user opens the app, he will see the background of the theme of the app, and only after a few moments the activity will be shown with the theme the user has chosen.
So, if the application has a white background, and the user has chosen a theme with a black background, the order will be:
Application shows a white background -> activity is starting and shows a black background.
In screenshots:
So this is wrong. In this case, I need it to show black-to-black background.
Only if the user has chosen a Holo-light based theme (which the app has by default), it works fine, as the color matches the one on the activity that is shown right when opening the app.
I had an idea of setting the app's theme to be empty of everything, hoping that no transition will be shown, using something like:
<application
...
android:theme="@android:style/Theme.Translucent.NoTitleBar" >
In fact, some people here suggested a similar solution.
This works, but it causes a bad experience, since on some devices it takes some time till the first activity is shown, and as such, there is a significant amount of time the user sees nothing at all, as if the app isn't being launched.
How do I solve this?
I've already tried setting the theme in the class that extends from Application, but it doesn't do anything, no matter where in this class I call it.
Settings. Under Display Options, tap Theme. Select the theme for this device: Light—White background with dark text.
Use the system setting (Settings -> Display -> Theme) to enable Dark theme. Use the Quick Settings tile to switch themes from the notification tray (once enabled). On Pixel devices, selecting the Battery Saver mode enables Dark theme at the same time.
A bit late, but this may be the answer. I discovered it by chance.
No entrance activity, no custom animations, no hacking. Simply an attribute in theme. Android buried this deep inside its resources.
Add the following attribute to your app theme:
<!--
~ From Theme.NoDisplay, this disables the empty preview window probably
~ with an incorrect theme.
-->
<item name="android:windowDisablePreview">true</item>
And your are done. Enjoy it!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With