Skip to main content
Create and apply a global CometChat UI Kit theme that matches your brand across light and dark modes.

When to use this

  • You want a single UI Kit theme that matches your app branding.
  • You need light and dark mode support with consistent colors.
  • You want to customize primary, background, or text colors across all UI Kit components.

Prerequisites


Core Concepts

The Kotlin XML UI Kit uses Android’s theme attribute system. All components read colors, typography, and fonts from XML theme attributes prefixed with cometchat.
  • CometChatTheme.DayNight — base theme built on Theme.MaterialComponents.DayNight.NoActionBar
  • Theme attributes like cometchatPrimaryColor, cometchatBackgroundColor1, etc. are defined in your themes.xml
  • Programmatic access via CometChatTheme.getPrimaryColor(context) and CometChatTheme.setPrimaryColor(color)
  • Dark mode via values-night/themes.xml overrides
Precedence:
  1. Programmatic overrides via CometChatTheme.set*() (highest)
  2. Activity-level theme
  3. Application-level theme
  4. CometChatTheme.DayNight defaults (lowest)

Quick Start

1

Create your theme

In app/src/main/res/values/themes.xml, extend CometChatTheme.DayNight:
themes.xml
2

Apply the theme

In AndroidManifest.xml, set the theme on your application:
AndroidManifest.xml
3

Build and verify

Run the app and confirm UI Kit screens use your theme in both light and dark mode.

Change the Primary Color

Override cometchatPrimaryColor in your theme:
themes.xml
Or set it programmatically:

Customize Common Theme Attributes

themes.xml
Or programmatically:

Add Dark Mode Support

Create app/src/main/res/values-night/themes.xml and override attributes for dark mode:
values-night/themes.xml
Android automatically applies values-night overrides when the system uses dark mode.

Apply a Theme to a Specific Activity

Set android:theme on a specific <activity> in AndroidManifest.xml:
AndroidManifest.xml
Activity-level themes override the application-level theme.

Color Token Reference