I am using DayNight theme with launch screen.
Launch screen is a layer-list with white background.
So when its day, white launch screen shows followed by white activity. But at night, white launch screen shows follwed by dark activity.
How can i change the background color in the launch screen according to the theme.
Cannot use custom color attrs because there is only a DayNight theme.
themes.xml
<resources> <!-- Base application theme. --> <style name="AppTheme" parent="Theme.AppCompat.DayNight.NoActionBar"> <item name="colorPrimary">@color/colorPrimary</item> <item name="colorPrimaryDark">@color/colorPrimaryDark</item> <item name="colorAccent">@color/colorAccent</item> <item name="android:colorControlNormal">@color/colorAccent</item> </style> <style name="LaunchTheme" parent="AppTheme"> <item name="android:windowBackground">@drawable/launch_screen</item> </style>
launch_screen.xml
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <item> <color android:color="@color/material_white"/> </item> <item> <bitmap android:gravity="center" android:src="@drawable/launch_logo" android:tileMode="disabled"/> </item>
Select Start > Settings > Personalization > Colors, and then choose your own color, or let Windows pull an accent color from your background.
Open your device's Settings app . Select Accessibility. Under "Display," select Color inversion. Turn on Use color inversion.
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. Other OEMs may or may not support this behavior.
Turn Dark theme on or off in your phone's settings On your phone, open the Settings app. Tap Display. Turn Dark theme on or off.
In addition to your default launch theme provide its night variant in appropriate resource directory.
<style name="LaunchTheme" parent="AppTheme"> <item name="android:windowBackground">@drawable/launch_screen_night</item> </style>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <item> <color android:color="@color/material_black"/> </item> <item> <bitmap android:gravity="center" android:src="@drawable/launch_logo" android:tileMode="disabled"/> </item>
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