user1529408
user1529408

Reputation: 319

Admob ad not completely showing up (small amount does appear)

I have a strange problem with admob sometimes only showing a small slice of the ad. Sometimes it is completely fine, However other times just shows the top (say the top 5%), and therefore there is an add there. I am putting them in OpenGL 1x as follows:

GLSurfaceView mGLSurfaceView;
LinearLayout ll;
FrameLayout fl;
AdView adView;

mGLSurfaceView = new GLSurfaceView(this);
mGLSurfaceView.setRenderer(this);
adView = new AdView(this, AdSize.BANNER, "xxxxxxxxxx");
adView.loadAd(new AdRequest()); 
ll=new LinearLayout(this); 
ll.addView(adView); // put in LinearLayout, as the ad can't be moved in layout but the layout can be moved when child of another layout
fl = new FrameLayout(this);
fl.addView(mGLSurfaceView); 
fl.addView(ll); // LinearLayout with ad put in FrameLayout. FrameLayout allows us to put other layouts within it where you want.
ll.setPadding(0, 5 /* amount of pixels from top*/ , 0, 0);
ll.setHorizontalGravity(0x11 /*center*/);
setContentView(fl);

Upvotes: 1

Views: 334

Answers (1)

jcw
jcw

Reputation: 5162

If your adview is not loading in time with the layout, you should try giving your ad the following traits (I have not written a java view before so I will write them in XML)

  • android:layout_width="320dp"

  • android:layout_height="50dp"

How to make AdView "occupy" space even while requesting an ad? (Android)

If your advise is being hidden by another view, then you should call

adview.bringToFront();

To bring your adview to the front of the page

Upvotes: 2

Related Questions