AdBanner

fun AdBanner(modifier: Modifier = Modifier, adsConfig: AdsConfig)(source)

A Composable function that displays a banner ad from Google AdMob.

This component handles the entire lifecycle of an AdView. It reads whether ads are enabled from rememberAdsEnabled and only attempts to load an ad if they are. The banner's visibility is animated, expanding when an ad is loaded and shrinking when it's hidden or fails to load.

The AdView is created with the composition's context, which is normally the Activity. It is destroyed when it is replaced (the ad unit, size or SDK readiness changed) and when the banner leaves composition, so neither the view nor that Activity outlives the screen.

Parameters

modifier

The Modifier to be applied to the ad container. The height is determined by the adsConfig.adSize, but the width will fill the maximum available space.

adsConfig

The AdsConfig object containing the necessary ad unit ID and ad size for the banner ad.