private async Task ShowBanner() { try { bannerLayout.Visibility = ViewStates.Visible; if (revmobBanner != null) { revmobBanner.Show(); return; } var revMob = await RevMobHelper.TryGetAdMobSessionAsync(startSessionListener); if (revMob == null) { HideBanner(); return; } revmobBanner = revMob.CreateBanner(this, "", showBannerAdListener); revmobBanner.SetAutoShow(true); ViewGroup view = FindViewById <ViewGroup>(Resource.Id.webViewContainer_banner); view.RemoveAllViews(); view.AddView(revmobBanner); } catch { } }
public void ShowBannerAd() { if (null != _bannerContainer || null != revmobBanner) { //There is already a banner ad displayed HideBannerAd(); } if (RevMob.Session() != null) { revmobBanner = RevMob.Session().CreateBanner(Game.Activity, "", bannerListener); revmobBanner.SetAutoShow(true); // A container to show the add at the bottom of the page _bannerContainer = new LinearLayout(Game.Activity); _bannerContainer.Orientation = Orientation.Horizontal; _bannerContainer.SetGravity(GravityFlags.CenterHorizontal | GravityFlags.Bottom); _bannerContainer.SetBackgroundColor(Color.Transparent); // Need on some devices, not sure why _rootLayout.AddView(_bannerContainer); _bannerContainer.AddView(revmobBanner); } }