capacitor-community / capacitor-community/admob
android: banner ad cropped when margin is large
- Dominant language
- Java
- Stars
- 296
- Forks
- 97
- Avg merge
- 2d 6h
- Merged PRs (30d)
- 7
Description
**Describe the bug**
On Android, banner ad is cropped when the margin is bigger than `(SCREEN_HEIGHT / 2) - BANNER_AD_HEIGHT`, which is exceeding the center of the screen. This problem occurs at all sizes and all positions. (except BannerAdPosition.CENTER, because it does not apply any margin) On iOS, the ad is not cropped and the margin is applied properly.
**To Reproduce**
Steps to reproduce the behavior:
1. Show any size of banner ad
2. Set the ad margin to be bigger than `(SCREEN_HEIGHT / 2) - BANNER_AD_HEIGHT`
3. Ad is cropped on Android
**Expected behavior**
Banner ad should be moved properly without any cropping.
**Screenshots**
#### Normal behavior (iOS)
#### Bad behavior (Android)
when more margin is applied!
**Smartphone (please complete the following information):**
- Device: Samsung S24
- OS: Android 15 (One UI 7.0)
- Browser: Android System WebView 140.0.7339.51
- Version: SDK 35
**Additional context (Reproduction code)**
```ts
AdMob.showBanner({
adId: "ca-app-pub-xxxxxx",
adSize: BannerAdSize.MEDIUM_RECTANGLE, // any size
position: BannerAdPosition.BOTTOM_CENTER, // any position
margin: 250, // quite big margin
isTesting: true,
});
```
Contributor guide
Research direction
Reproduce the issue through AdMob.showBanner with a large margin, such as 250, using a non-center position and any banner size on Android. Investigate the Android banner positioning path and compare its behavior with the stated iOS result. Done means the banner moves to the requested position without cropping when the margin exceeds the given threshold.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, java, typescript
- Domain
- mobile
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100