Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change background color in launch screen when using DayNight theme

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> 

like image 517
Amit Jayant Avatar asked Sep 23 '16 13:09

Amit Jayant


People also ask

How do I change the background color mode?

Select Start > Settings > Personalization > Colors, and then choose your own color, or let Windows pull an accent color from your background.

How do I change my background from dark to white?

Open your device's Settings app . Select Accessibility. Under "Display," select Color inversion. Turn on Use color inversion.

How to set Day and night theme in Android application?

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.

How do you disable night mode in my application even if night mode is enable in Android?

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.


1 Answers

In addition to your default launch theme provide its night variant in appropriate resource directory.

res/values-night/themes.xml

<style name="LaunchTheme" parent="AppTheme">     <item name="android:windowBackground">@drawable/launch_screen_night</item> </style> 

res/drawable/launch_screen_night.xml

<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> 
like image 90
Eugen Pechanec Avatar answered Sep 21 '22 15:09

Eugen Pechanec