Google Mobile Ads SDK for React Native supports fixed ad sizes for your banner ads. For details on banner ads, see Set up banner ads.
Set a fixed ad size
To set a fixed ad size, pass a fixed AdSize constant
when calling the BannerAd.load method.
The following example passes the ad size and ad unit ID, logs a message on success, and logs an error on failure:
Replace AD_UNIT_ID with your ad unit ID.
Choose a banner size
The following table lists the standard banner sizes:
| Size in dp (width x height) | Description | Availability | AdSize constant |
|---|---|---|---|
| 320x50 | Banner | Phones and tablets | AdSize.BANNER |
| 320x100 | Large banner | Phones and tablets | AdSize.LARGE_BANNER |
| 300x250 | IAB medium rectangle | Phones and tablets | AdSize.MEDIUM_RECTANGLE |
| 468x60 | IAB full-size banner | Tablets | AdSize.FULL_BANNER |
| 728x90 | IAB leaderboard | Tablets | AdSize.LEADERBOARD |
Ensure sufficient container size
The view container size to place your banner ad must be at least as large as
the banner. Padding decreases the size of your container. If the banner doesn't
fit the container, the ad doesn't show and the request fails. Refresh requests
fail with a LoadAdError object, which invokes the
onAdFailedToRefresh callback.
On Android, Google Mobile Ads SDK for React Native logs a warning in Logcat:
W/Ads: Not enough space to show ad. Needs 320x50 dp, but only has 288x495 dp.