Skip to content

Android ColorGroup and Improved Dark Mode Support

Xojo 2025 Release 1 adds support for ColorGroups and improves dark mode support for Android.

ColorGroups

Now available for Android, ColorGroups are a way to have a color that can differ between light mode and dark mode. There are three types of ColorGroups: Single, Dual and Named. Add a ColorGroup to your project using Insert->ColorGroup.

A Single ColorGroup is not really a group, it is just a single color. A Dual ColorGroup has separate colors for light and dark mode. A Named ColorGroup gets the color from the system or, in the case of Android, the app theme. You can see the available options in the Android submenu.

For the most part you can use ColorGroups just like you can with other project types. Android does have one addition, the ColorGroup.ToColor() method lets you specifically convert a ColorGroup to a Color. Normally this is done automatically by Operator_Convert, but support for that in Android is still young and this method serves as a workaround should you run into issues with it.

In the Inspector for controls with ColorGroup properties, such as MobileButton.CaptionColor, you can use the ColorGroup selector to manually choose a Color or a ColorGroup:

In addition to working with ColorGroups as project items, you can also create ColorGroups in code:

Var cg1 As New ColorGroup()
cg1.AddColorPair(ColorGroup.Platforms.Mobile, Color.Blue, Color.Teal)

You can also use Android system color names to create a named color:

Var cg2 As New ColorGroup()
cg1.AddNamedColor(ColorGroup.Platforms.Mobile, "holo_purple")

Refer to the Android docs for R.color to see what the system color names are. Keep in mind that not all names are available on all versions Android OS.

For more about ColorGroups, refer to the documentation.

Dark Mode Support

ColorGroups are particularly useful with dark mode and starting with 2025r1, Android projects now default to having Supports Dark Mode switched on.

Several controls have been improved to work better in dark mode at runtime.

In addition, the Android Layout Editor has been improved to look better when working in dark mode and now shows controls with dark mode variants.

Download the latest Xojo release and get access to these new features and more.

Paul learned to program in BASIC at age 13 and has programmed in more languages than he remembers, with Xojo being an obvious favorite. When not working on Xojo, you can find him talking about retrocomputing at Goto 10 and on Mastodon @lefebvre@hachyderm.io.