Android Question FirebaseAdMob ads in a Panel?

Pencil3

Member
Licensed User
I have a panel made in the Visual Designer that I would like to load a smart banner into, but am missing something as no ad displays (I can display them fine when adding to the Activity).

B4X:
Dim AdPanel As Panel
BannerAd.Initialize2("BannerAd", "ca-app-pub-XXXXXXX/XXXXXXX", BannerAd.SIZE_SMART_BANNER)
AdPanel.AddView(BannerAd, 0dip, 50%y - 32dip, 100%x, 32dip)
BannerAd.LoadAd
 

Pencil3

Member
Licensed User
Still no luck, I must be doing something else wrong. I have attached a zip of a test project, could someone please look at it?

Try it with:
B4X:
AdPanel.AddView(BannerAd, 0dip, AdPanel.Height / 2 - 32dip, AdPanel.Width, 32dip)
 

Attachments

  • Ad.zip
    9.7 KB · Views: 164
Upvote 0

Pencil3

Member
Licensed User
Also tried adding the panel by code, ad does not display.
B4X:
Dim AdPanel As Panel
AdPanel.Initialize("")
AdPanel.Color = 0xFFFFFFFF
Activity.AddView(AdPanel,0dip,400dip,100%x,25%y)
BannerAd.Initialize2("BannerAd", "ca-app-pub-XXXXXXXXXXXXXXXX/XXXXXXXXXX", BannerAd.SIZE_SMART_BANNER)
AdPanel.AddView(BannerAd, 0dip, 25%y, 100%x, 100dip)
BannerAd.LoadAd
 
Upvote 0

ilan

Expert
Licensed User
Longtime User
Also tried adding the panel by code, ad does not display.
B4X:
Dim AdPanel As Panel
AdPanel.Initialize("")
AdPanel.Color = 0xFFFFFFFF
Activity.AddView(AdPanel,0dip,400dip,100%x,25%y)
BannerAd.Initialize2("BannerAd", "ca-app-pub-XXXXXXXXXXXXXXXX/XXXXXXXXXX", BannerAd.SIZE_SMART_BANNER)
AdPanel.AddView(BannerAd, 0dip, 25%y, 100%x, 100dip)
BannerAd.LoadAd

the reason you dont see the banner is very simple.

your panel "Adpanel" has the height of 25%y. and you add your adview (banner ad) at top of 25%y that means that your ad banner starts where your panel size ends. how do you want to see like that the banner? o_O

B4X:
Activity.AddView(AdPanel,0dip,400dip,100%x,25%y)

AdPanel.Height = 25%y

AdPanel.AddView(BannerAd, 0dip, 25%y, 100%x, 100dip)

BannerAd.top = 25%y

o_Oo_Oo_O
 
Upvote 0
Top