Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

I want to create a red "night mode" for my Android app

I'm creating an app for use by pilots. It mostly uses TextView, EditText, Button, etc. In other words, not very graphics-heavy.

When used at night, I'd like for the user to be able to switch to a "night mode" where everything on screen is red and black... like the Google Sky Map app. (This is important for pilots because the color red does not destroy the eye's natural night vision adaptation as other colors do.)

What's the best way to do this? I found APIs like ColorFilter, etc. but I'm not sure how I'd apply these app-wide.

like image 678
Roger Avatar asked Sep 09 '11 03:09

Roger


People also ask

How do I Turn on night mode on my Android phone?

Once the app has finished installing, open it up and tap the “Enable Night Mode” button. It should automatically open a new menu within the System UI Tuner and show a toast notification at the bottom that reads “Yay, you should now have a quick toggle for Night Mode available.” You’re so close now.

How to add dark mode to your Android app?

Makes it easier to use device in a low-light. How to add dark mode to your android app? Create a layout and add a button or switch to toggle On/Off Dark Mode Now copy the values folder and paste it into the same directory and rename it to “values-night”

How to enable night mode on Android devices to avoid eye strain?

OEMs have started offering the Night Mode feature on Android to avoid eye strain when using your device in the dark. Here’s how to enable Night Mode. To enable Night Mode, go to Settings-->Display-->Night Mode. You can set it to enable the feature manually or pre-set a time of day that you want the feature to turn on automatically.

How to improve the readability of your Android apps during the night?

We can do so manually or let Android detect the time of the day implicitly from your phone. This theme enhances the readability and usability of your application during the night by replacing the white flashy background with a darker one. Many reader applications have already deployed this theme in their apps.


1 Answers

If you're simply talking about changing the colours of the various views within the layout and not the structure of the layout itself, then I'd suggest you simply do this using styles.

i.e. Define two sets of styles for the various views which make up your layout - one set for night mode and one for day mode. In your activity, it then becomes a case of calling setStyle() on each of your views to toggle it between night and day.

Coming up with a sensible naming convention and parentage scheme for your styles will make your life a lot easier. e.g. MyText.Large vs MyText.Large.Night.

The Android developer doc on Themes and Style is a good starting point.

like image 174
tomtheguvnor Avatar answered Oct 20 '22 02:10

tomtheguvnor