Switch app theme at runtime?

Inman

Well-Known Member
Licensed User
Longtime User
An app of mine has Holo Light theme set in the Manifest file. Now many of my users are requesting a dark color mode for the app. So I need to switch the theme to Holo Dark and also change the label colors and other stuff manually.

So ideally I should give the user an option to switch theme in the settings screen and then switch the theme on runtime. There are some java solutions mentioned at Stackoverflow:

Change and apply theme at runtime in Android - Stack Overflow
How to change current Theme at runtime in Android - Stack Overflow

How can we do this in B4A?
 

Inman

Well-Known Member
Licensed User
Longtime User
I understand.

What if we store this theme selection value in a file, which the Java code can read and set, even before our B4A code starts? I know it is not the ideal solution but I would really like to have this feature. With Samsung Galaxy phones taking the lead, many users believe the Super AMOLED screens consume lesser battery when the colors are dark. Also some users access the app at night time and they don't want the bright light on their faces.

Please consider this possibility.
 
Upvote 0

Inman

Well-Known Member
Licensed User
Longtime User
Oh. Ok. No problem, I will wait.

I suppose you were busy with this major upgrade, particularly the rapid debugger which is a great achievement. I hope you will be able to work on this feature in one of the subsequent minor updates.
 
Upvote 0

Inman

Well-Known Member
Licensed User
Longtime User
Erel, please consider this request when you get time. Most of my users are requesting a dark theme for my app and I cannot implement the runtime theme switching without your help.
 
Upvote 0

Inman

Well-Known Member
Licensed User
Longtime User
Yes, I understand that. But many popular apps, particularly clients of popular services like Twitter, Reddit etc. offer the feature for the user to switch to dark or light (or night or day) theme at runtime. Mine is such an app and users have been requesting for dark theme from day 1. I have been holding out on releasing version 2 of the app as I want to include the theme switching feature; which is why I am troubling you. :(
 
Upvote 0

NJDude

Expert
Licensed User
Longtime User
You can do that easily, (changing themes) just create the "light" and "dark" graphics needed, look at what I did on one of my apps: Road Sidekick, on that app, you can change to DAY or NIGHT theme just by long tapping on the TIME on top of the screen or saying the voice command: "Change theme"
 
Last edited:
Upvote 0

Inman

Well-Known Member
Licensed User
Longtime User
I understand your approach NJDude and it is essential, but only after switching the theme, IMO. While you can manually change foreground and background colors of almost all views, there is some stuff that can be modified only by setting the theme. For example - the popup that is displayed during ProgressDialogShow, Msgbox, the color of PreferenceActivity etc... So to complete the switching experience, the theme needs to be set like those native Java apps.
 
Upvote 0
Top