AI Search

Android

Introduction

UI customisation capabilities are available with our SDK. This enables developers to tailor color schemes and font styles of all UI components within the InMobi CMP, ensuring seamless integration with the host application's UI.

Customisation for Android apps can be done both from the Themes tab on the InMobi CMP portal and in the code of the SDK. For steps to customize color and font through the InMobi CMP portal, see Create App Theme.

Note

While both color and font customisation can be done through code, InMobi CMP gives priority to customisations enabled through the portal. First, we will consider the customisations from the portal; if there are none, we will consider the customisations made through code. In case there are no changes made through code, we will apply the default colours and fonts.

This section details how to utilize various configuration options for text styles and colors on Android.

Configuration

You can control light/dark mode by using ThemeMode while calling startChoice method. It can take three values:

  1. LIGHT - choice sdk always behaves in light mode
  2. DARK - choice sdk always behaves in dark mode
  3. AUTO - choice sdk behaves the same mode as device configured

Color customisation via Code

You can pass the ChoiceColor model to set themes in light and dark mode. If only one model is passed in AUTO themeMode, InMobi CMP SDK will use the same model for both light and dark mode. To create your theme, follow the steps: 

  1. Create a ChoiceColor model and set all the necessary colors for that model.
  2. Create the ChoiceStyle object through the builder and set the appropriate ChoiceColor object for light and dark mode resources.
  3. Pass the ChoiceStyle object in the startChoice method.

Example


fun initChoice() {
  ChoiceCmp.startChoice( 
      app = application, 
      packageId = packageId,  
      pCode = "your pcode",  
      callback= choiceCmpCallback,  
      choiceStyle = ChoiceStyle.Builder().setThemeMode(ThemeMode.AUTO).
            setLightModeColors(getColors()).
            setDarkModeColors(getColors()).build()
  )
}
    
private fun getColors(): ChoiceColor {
    val choiceColor = ChoiceColor()
    choiceColor.dividerColor = getColorInt(R.color.dividerColor)
    choiceColor.tabBackgroundColor = getColorInt(R.color.tabBackgroundColor)
    choiceColor.tabTextColor = getColorInt(R.color.tabTextColor)
    choiceColor.searchBarBackgroundColor = getColorInt(R.color.searchBarBackgroundColor)
    choiceColor.searchBarForegroundColor = getColorInt(R.color.searchBarForegroundColor)
    choiceColor.toggleActiveColor = getColorInt(R.color.toggleActiveColor)
    choiceColor.toggleInactiveColor = getColorInt(R.color.toggleInactiveColor)
    choiceColor.globalBackgroundColor = getColorInt(R.color.globalBackgroundColor)
    choiceColor.titleTextColor = getColorInt(R.color.titleTextColor)
    choiceColor.bodyTextColor = getColorInt(R.color.bodyTextColor)
    choiceColor.menuTextColor = getColorInt(R.color.menuTextColor)
    choiceColor.linkTextColor = Color.parseColor(R.color.linkTextColor)
    choiceColor.buttonTextColor = getColorInt(R.color.buttonTextColor)
    choiceColor.buttonBackgroundColor = getColorInt(R.color.buttonBackgroundColor)
    choiceColor.buttonDisabledTextColor = getColorInt(R.color.buttonDisabledTextColor)
    choiceColor.buttonDisabledBackgroundColor = getColorInt(R.color.buttonDisabledBackgroundColor)
    return choiceColor
}

private fun getColorInt(colorRes: Int): Int {
    return ContextCompat.getColor(this, colorRes)
}

Fonts customisation

If you wish to customise the fonts used in the Choice CMP, follow the instructions below:

  1. Create a font folder inside the res directory of your project if it hasn't been created already.
  2. Add the respective font files that you want to use to this newly created font folder.
  3. Include their corresponding IDs in the resources parameter when calling the startChoice method. The table below provides details on the two types of supported fonts and their corresponding property names in the ChoiceStyle class in the CMP:
Property name Description
regularFont Name of the font used for the CMP
boldFont Name of the bold font used for the CMP

Below is an example demonstrating how the startChoice call will appear once you've integrated custom fonts:

ChoiceCmp.startChoice( 
      app = application, 
      packageId = packageId,  
      pCode = "your pcode",  
      callback= choiceCmpCallback,  
      choiceStyle = ChoiceStyle.Builder().setThemeMode(ThemeMode.AUTO).
            setLightModeColors(getColors()).
            setDarkModeColors(getColors()).
            setRegularFont(R.font.open_sans_regular).
            setBoldFont(R.font.luckiest_guy).build()
  )

On This Page

Last Updated on: 24 Feb, 2026