gpt4 book ai didi

android - Admob + Andengine 仅在第二次请求时显示广告

转载 作者:搜寻专家 更新时间:2023-11-01 08:52:27 26 4
gpt4 key购买 nike

问题是:广告在第一次请求时不显示,但在发出第二次请求时,它显示正确。在它发出第二个请求前大约 2 秒,第一个请求的广告出现了。有任何想法吗?谢谢,

编辑:我将引力更改为顶部,现在它第一次显示,但只显示广告的上半部分,奇怪,有什么想法吗?

@Override
protected void onSetContentView() {

if(adView != null){
return;
}

final FrameLayout frameLayout = new FrameLayout(this);
final FrameLayout.LayoutParams frameLayoutLayoutParams =
new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT,
FrameLayout.LayoutParams.MATCH_PARENT);

final FrameLayout.LayoutParams adViewLayoutParams =
new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT,
FrameLayout.LayoutParams.WRAP_CONTENT,
Gravity.CENTER_HORIZONTAL|Gravity.BOTTOM);

adView = new AdView(this);
adView.setAdSize(AdSize.BANNER);
adView.setAdUnitId(getResources().getString(R.string.ad_unit_id));
adView.setAdListener(new ToastAdListener(this));
adView.loadAd(new AdRequest.Builder().build());

this.mRenderSurfaceView = new RenderSurfaceView(this);
mRenderSurfaceView.setRenderer(mEngine,this);

final android.widget.FrameLayout.LayoutParams surfaceViewLayoutParams =
new FrameLayout.LayoutParams(super.createSurfaceViewLayoutParams());

frameLayout.addView(this.mRenderSurfaceView, surfaceViewLayoutParams);
frameLayout.addView(adView, adViewLayoutParams);

this.setContentView(frameLayout, frameLayoutLayoutParams);
}

@Override
protected void onPause() {
if(adView!=null){
adView.pause();
}
super.onPause();
}

@Override
protected void onResume() {
super.onResume();
if(adView!=null){
adView.resume();
}
}

@Override
protected void onDestroy() {
if(adView!=null){
adView.destroy();
}
super.onDestroy();
}

最佳答案

通过添加行为我解决了问题adView.setBackgroundColor(android.graphics.Color.TRANSPARENT);

关于android - Admob + Andengine 仅在第二次请求时显示广告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21889441/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com