0

I am trying to integrate Inmobi banner ads into my app programmatically but I'm having a problem regarding the size of the banner ad. I have the following code snippet in my Launcher class:

RelativeLayout.LayoutParams bannerLp = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
        bannerLp.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE);
        bannerLp.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE);
        layout.addView(bannerAd, bannerLp);
        setContentView(layout);
        bannerAd.load();

It doesn't show any ad on phone. But when I set the hight parameter from WRAP_CONTENT to 80. It fits perfectly at the bottom. But when tried same on a phone with bigger screen size, it appears small. I used the same code snippet for AdMob ads and havent faced this difficulty. I had always set the with parameter as MATCH_PARENT and height parameter as WRAP_CONTENT. Why is it no displaying anything when using Inmobi?

1 Answers1

1

According to InMobi integration guide :

You should specify the banner view dimensions in pixel units when setting the layout parameters for the banner ad. Also, it is a programming error to supply WRAP_CONTENT as the layout parameters for a banner ad. This constraint applies whether you create a banner in your XML layout resource file or in code.

Abhishek Aryan
  • 19,936
  • 8
  • 46
  • 65