Dynamic, Light and Dark Theme
  • 24 May 2024
  • 2 Minutes to read
  • Contributors
  • Dark

Dynamic, Light and Dark Theme

  • Dark

Article summary

The Vuzix Blade has three display modes (Dynamic, Light and Dark modes). The display modes provide an optimal display experience in different ambient lighting conditions.

Those styles are automatically changed by the BladeOS based on the front-facing sensors.

The developer can take advantage of this feature and use HUD resources to allow the application Theme to change.

It can also be used to Allow other parts of your application (for instance, Home Screen Widget) to dynamically adjust as well.

The com.vuzix.hud.resources class defines two styles. The two theme styles: HudTheme and HudTheme.Light.

This corresponds to the two display modes of the Vuzix Blade.

Note: The com.vuzix.hud.actionmenu classes have a dependency on com.vuzix.hud.resources.

Thus, since com.vuzix.hud.actionmenu classes are in the dependencies section of the build.gradle file, Android Studio also downloads the resources classes.

Extend HUDTheme Styles

A styles.xml (res/values.styles.xml) file will be created by Android Studio.

You will need to modify the file to have two separate themes that reference HUD resource main themes.

Create an AppTheme that extends the HudTheme from com.vuzix.hud.resources and also create a AppTheme.Light that extends the HudTheme.Light from the same package.

For more details, you can read the JavaDocs or view the details on the parent themes by exploring inside the hud-resources-1.0 file.


<style name="AppTheme" parent="HudTheme">
	<!-- Customize your theme here. -->
<style name="AppTheme.Light" parent="HudTheme.Light">
	<!-- Customize your theme here. -->


DynamicThemeApplication Class

Extend the com.vuzix.hud.resources.DynamicThemeApplication class to create an application that will dynamically change themes depending on the current display mode.

If you utilize this feature, the application will automatically receive a notification from the system and handle the theme change if correctly configured.

In the example application, a new BladeSampleApplication class is created which extends com.vuzix.hud.resources.DynamicThemApplication.

Note: Be sure to set the Superclass as com.vuzix.hud.resources.DynamicThemeApplication.

Create New Class Extending DynamicThemeApplication

Once the BladeSampleApplication class is generated by Android Studio, two methods must be overridden.

The methods that will need to be extended are getNormalThemeResId and getLightThemeResId. These two classes return the new styles defined in the styles.xml file modified above.


@Override protected int getNormalThemeResId() {
	return R.style.AppTheme;
@Override protected int getLightThemeResId() {
	return R.style.AppTheme_Light;

BladeSampleApplication Class

Next we have to register the new application in the AndroidManifest.xml file.

This is shown on line 6 of the screen below.



Application defined in AndroidManifest.xml

Now that your application is created and registered, your application will automatically change based on the BladeOS understanding of ambient light conditions.

Dynamic Themes Broadcast

BladeOS will send a broadcast with the following action:

  • com.vuzix.intent.action.UI_DISPLAY_MODE

This broadcast can also be received manually to perform any desire actions.

To receive and modify this broadcast you can just follow the normal Android OS Broadcast development work.

We will create a custom broadcast receiver to intercept that message. Once we have that message, we can use it to do custom actions or signal other parts of the application to update.

We will use this feature later for Home Screen widgets, but lets create it now for simplicity.

First we create a new Java class (File > New > Other > Broadcast Receiver) and provide the following information:

  • Name: Name of Class

Once the file gets generated, the new class will open up and have a TODO of implement method.

For now we can delete all the code inside the method and leave it blank.

You can use this method to override and do custom work desired when the BladeOS signals for a dynamic theme change request.

Now we go to the Android manifest and tell the system which broadcast this receiver should receive.

We do this by adding an Intent Filter for : "com.vuzix.intent.action.UI_DISPLAY_MODE"


	<action android:name="com.vuzix.intent.action.UI_DISPLAY_MODE" />

You now have a broadcast receiver to intercept and perform custom work on a dynamic theme change request.

Now lets continue the sample project by creating and usingActionMenuActivity and ActionMenu.

Was this article helpful?

What's Next