我有一个奇怪的问题,有时只显示一小部分广告。有时它完全没问题,但有时只显示顶部(比如前5%),因此有一个补充。我将它们放在OpenGL 1x中,如下所示:
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);
答案 0 :(得分:1)
如果您的广告视图未及时加载广告,则应尝试为广告提供以下特征(我之前没有编写过java视图,因此我会用XML编写)
android:layout_width="320dp"
android:layout_height="50dp"
How to make AdView "occupy" space even while requesting an ad? (Android)
如果您的建议被其他视图隐藏,则应致电
adview.bringToFront();
将您的广告视图带到页面的前面