I'm trying to build a Java application with Android Studio. I plan to make 2 versions: a day version and a night version. How can I change the background of my xml file according to the mode it is set? That is, if it is day, the background must be white, if it is night it must be blue.
CodePudding user response:
There are a few ways to go about this, one way is the following:
You need to create 2 files under the res/values/colours. One as the default and one for night.
In each of those files create something like the following:
<color name="application_background">HEX_CODE_VALUE</color>
Then in your desired layout simply add application_background as the background colour - assuming you are using XML layouts.