NativeAdStyle

data class NativeAdStyle(val badgeShape: NativeAdBadgeShape? = null, val badgeCornerRadiusDp: Int? = null, val badgeColor: Color = Color.Unspecified, val headlineTextSizeSp: Float? = null, val headlineBold: Boolean? = null, val headlineColor: Color = Color.Unspecified, val bodyTextSizeSp: Float? = null, val bodyMaxLines: Int? = null, val bodyColor: Color = Color.Unspecified, val callToAction: NativeAdCallToActionStyle = NativeAdCallToActionStyle.Filled, val iconInsetDp: Int? = null)(source)

Per-screen look for a native ad.

A native ad only works when it looks like it belongs on the screen it is on, and screens differ: one draws its icons in a circle, the next cuts them from a Material shape, one uses filled buttons, the next uses text buttons. A style says how this one placement should look, without the host having to build a view tree of its own.

It overrides only what it names. Every value has a default that means "leave it as the presentation built it", so a style that sets one property changes one property. That also makes styles safe to combine with a custom NativeAdViewFactory: the factory decides the arrangement, the style decides the finish.

It is applied in the same pass as NativeAdPalette, on views that already exist, so changing a style repaints the ad rather than rebuilding it. Rebuilding would discard the loaded ad.

Constructors

Link copied to clipboard
constructor(badgeShape: NativeAdBadgeShape? = null, badgeCornerRadiusDp: Int? = null, badgeColor: Color = Color.Unspecified, headlineTextSizeSp: Float? = null, headlineBold: Boolean? = null, headlineColor: Color = Color.Unspecified, bodyTextSizeSp: Float? = null, bodyMaxLines: Int? = null, bodyColor: Color = Color.Unspecified, callToAction: NativeAdCallToActionStyle = NativeAdCallToActionStyle.Filled, iconInsetDp: Int? = null)

Properties

Link copied to clipboard

Badge fill. Color.Unspecified keeps the palette's neutral surface, which is right for a card that sits on its own and wrong on a screen whose icons are all primaryContainer.

Link copied to clipboard

Corner radius of the badge when there is no badgeShape. null keeps the shared radius.

Link copied to clipboard

Silhouette the icon badge is filled with, from rememberNativeAdBadgeShape. null keeps the rounded square at badgeCornerRadiusDp.

Link copied to clipboard

Body color. Color.Unspecified keeps the palette's onSurfaceVariant.

Link copied to clipboard

Body line cap. null keeps the presentation's own. Lower it when a long description would make the ad taller than the rows beside it.

Link copied to clipboard

Body size. null keeps the presentation's own.

Link copied to clipboard

Whether the call to action is a filled pill or a text button.

Link copied to clipboard

Whether the headline is bold. null keeps the presentation's own. A headline heavier than the titles around it reads as an intruder.

Link copied to clipboard

Headline color. Color.Unspecified keeps the palette's onSurface.

Link copied to clipboard

Headline size. null keeps the presentation's own.

Link copied to clipboard

Padding inside the icon badge. A non-null value centres the full advertiser icon without cropping it, leaving the badge shape visible. null keeps the presentation's inset.