SDKsAndroid

Appearance

Theme Koah ads, size your slots, and choose between card chrome and borderless rendering.

Theming

πŸ’‘
See how it looks in the playground.

Wrap your composable tree with ProvideKoahTheme once at the root. Every Koah ad below it picks the theme up automatically:

import androidx.compose.ui.graphics.Color
import com.koahlabs.android.KoahColorScheme
import com.koahlabs.android.KoahTheme
import com.koahlabs.android.ProvideKoahTheme

ProvideKoahTheme(
    theme = KoahTheme(
        colorScheme = KoahColorScheme.AUTO,
        accentColor = Color(0xFF22C55E),
    )
) {
    // Your app content here
}

For the full list of theme properties, see Theme properties in the reference.

Sizing

Bound each slot per axis with the width and height parameters β€” each takes a KoahAxisSize, and each axis is independent:

  • null (the default) β€” unbounded: the card wraps its content within whatever space the parent gives it. This keeps the most formats in play, but a short or narrow parent still narrows the set
  • KoahAxisSize.range(min, max) β€” wrap content within a dp band. At least one of min / max is required; passing neither throws. An unbounded axis is spelled null, not range()
  • KoahAxisSize.fixed(dp) β€” exactly this size
  • KoahAxisSize.fill() β€” fill the parent along this axis. Requires a parent that bounds that axis: placing it on an axis the parent leaves unbounded β€” height inside a LazyColumn or verticalScroll, width inside a horizontally-scrolling Row β€” throws at first layout. Use fixed or range on a scroll axis

The SDK offers the server only the ad formats that fit the resolved bounds, and text formats receive a length budget so copy is sized to the slot. If the slot turns out too short for the format the server picked, the card renders nothing at all rather than clipping: KoahEvent.SlotTooSmall fires and no impression is tracked for that ad.

πŸ’‘

Leave an axis unbounded when you can β€” more formats stay eligible, improving fill rates and revenue.

KoahCard(
    adContext = KoahAdContext.Conversation(question = q, answer = a),
    width = KoahAxisSize.fill(),
    height = KoahAxisSize.range(max = 400),
    cacheKey = messageId,
)

See Formats for the full sizing model and bounds. The legacy overrideMaxWidth / overrideMaxHeight parameters are removed as of 1.0 β€” replace each with range(max = …) β€” and the older size / KoahAdSize API was removed in 0.3.0. See the migration guide for the full upgrade path.

Card chrome

Chrome is a choice of component on Android β€” both take the same arguments and share the same fetch / impression / event behavior. Use KoahCard for the standard chrome (surface background, border, padding), or KoahAd to render borderless and embed directly into a chat row, list cell, or comment card when your surface already provides framing.

import com.koahlabs.android.KoahCard

// Standard chrome β€” surface background, border, padding
KoahCard(
    adContext = KoahAdContext.Conversation(question = q, answer = a),
    cacheKey = messageId,
)
Was this helpful?