1

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);
user1529408
  • 219
  • 1
  • 3
  • 10
  • 1
    Is it getting covered up by whatever else is in your frame layout? – jcw Nov 13 '12 at 20:30
  • @jcw. I don't know if it's geting covered, but I don't think so as a bit is there (it might be though). What do you mean about the frame layout? – user1529408 Nov 13 '12 at 21:06
  • 1
    Sorry, I jumped to conclusions about which view your adview was being added to. Try adding a text view in place of your add with some text in it to see if it is covered up too – jcw Nov 13 '12 at 21:11
  • @jcw. Ah, good idea. With the ad it can be a bit tempermental (For times it's fine, and then others it does this thingy), so it maybe fine at first but then in a few days it does this, So if I end up finding it's doing the same with textview what would be your solution (as you might not be around then)? – user1529408 Nov 13 '12 at 21:35
  • 1
    If that is the case, post your XML layout, and I will look through that – jcw Nov 13 '12 at 21:39
  • @jcw. I have no XML I am doing it all in java (I have even deleted the layout folder). What I put above are all my contents. – user1529408 Nov 13 '12 at 21:41
  • In that case I am not sure, try posting the rest of your java layout(assuming it is not huge) along with a screen shot of what it looks like – jcw Nov 13 '12 at 21:44
  • @jcw. That pretty much it. I will have a look though to make sure. However I just thought of something, could it be that the admob is not loading intime for the layouts (frame/linear) to allocate size? If so any ideas how to overcome this? Thanks for this by the way! – user1529408 Nov 13 '12 at 21:48

1 Answers1

2

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

Community
  • 1
  • 1
jcw
  • 5,132
  • 7
  • 45
  • 54
  • Ah another good idea, I will give this a go, thanks for the link. – user1529408 Nov 13 '12 at 22:04
  • My edit covers the other scenario - it came from this post - http://stackoverflow.com/questions/4392179/how-to-bring-a-view-to-front-without-calling-bringtofront – jcw Nov 13 '12 at 22:11