Coders Packet

Changing App Theme and Styles in Android using Java

By Saptneel Sharma

The app implements an android activity that can switch night mode and apply multiple themes using Java

More often than not, users want to have multiple styles and color schemes available to them in an app. This application does exactly that.

You can turn the night mode on and off or select a different color style from the given samples.

By default, the night mode and the style are set to the system default. The Main Activity shows you a sample of basic Android views to show you how the current theme and style look. Users can go to 'Styles and Theme' from the menu options to change them.

After selecting the style, it is immediately applied to the current activity and when you go back to the home activity, the style is applied after refreshing it.

 

For developers:

Any developer can add the code for the 'StylesAndTheme' activity to their app and then apply it in all other activities with a few changes.

A developer can also easily add more styles by simply adding the colors in the colors.xml and then copy-pasting the layout for a style material card and changing a few variables and then add a new 'applyStyle' method.

This makes it easy to add multiple themes to any of your apps if you are a developer.

 

Note: A .apk can be found in the zip packet.

App Screenshot 1 App Screenshot 2 App Screenshot 3

 

Download project

Reviews Report

Submitted by Saptneel Sharma (saptneel)

Download packets of source code on Coders Packet