Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change the background/text color of a layout when daynight theme is used

I'm using Theme.AppCompat.DayNight and I want to customize a certain layout background and text color to change depending on whether it's day or night mode .

Here's what I tried so far:

<style name="AppTheme" parent="Theme.AppCompat.DayNight.NoActionBar">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/primaryDarkColorAmber</item>
    <item name="colorPrimaryDark">@color/primaryDarkColorAmber</item>
    <item name="colorControlActivated">@color/primaryDarkColorAmber</item>
</style>

<style name="PopUpTheme" parent="AppTheme">
    <!-- layout custom theme there's no darkBackground value...!! -->
    <item name="android:background">@color/popup_background</item>
</style>
like image 459
potato Avatar asked Dec 17 '22 17:12

potato


1 Answers

first of all create res/values-night this directory then add same as res/value file you can copy and replace to color and after that when you change day or night theme you can get color according to your style

like image 108
Vishal kumar singhvi Avatar answered Dec 21 '22 11:12

Vishal kumar singhvi