人。我在项目中有两个PublisherAdViews(这里是测试应用程序),大小为BANNER和MEDIUM_RECTANGLE。 BANNER尺寸工作得很好,但MEDIUM_RECTANGLE不是,我只能看到屏幕上的瞥见(如阴影弹出)然后只是屏幕背景。 AdLisneter告诉我,广告已加载,一切正常。不知道该怎么办。我尝试在xml中以编程方式添加PublisherAdViews,但没有结果。 这是XML
<com.google.android.gms.ads.doubleclick.PublisherAdView
android:id="@+id/ad_view_small"
android:layout_width="match_parent"
android:layout_height="wrap_content"
ads:adSize="BANNER"
ads:adUnitId="/108874508/LEBFILE-MOBILEAPP-320x50">
</com.google.android.gms.ads.doubleclick.PublisherAdView>
<com.google.android.gms.ads.doubleclick.PublisherAdView
android:id="@+id/ad_view_big"
android:layout_width="match_parent"
android:layout_height="wrap_content"
ads:adSize="MEDIUM_RECTANGLE"
ads:adUnitId="/108874508/LEBFILES-300X250-HP-MOBILE">
</com.google.android.gms.ads.doubleclick.PublisherAdView>
这是实现
PublisherAdRequest adRequest = new PublisherAdRequest.Builder().build();
PublisherAdView mAdView2 = (PublisherAdView) findViewById(R.id.ad_view_small);
mAdView2.loadAd(adRequest);
PublisherAdView mAdView1 = (PublisherAdView) findViewById(R.id.ad_view_big);
mAdView1.loadAd(adRequest);
正如您所看到的那样相同,但广告并不显示。 这是我尝试手动添加广告的方式,再次没有结果。
rlBanner = (RelativeLayout)findViewById(R.id.rlBanner);
PublisherAdView adView = new PublisherAdView(MainActivity.this);
adView.setAdSizes(AdSize.MEDIUM_RECTANGLE);
adView.setAdUnitId("/108874508/LEBFILES-300X250-HP-MOBILE");
adView.setId(999);
adView.loadAd(adRequest);
@SuppressWarnings("deprecation")
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
params.addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE);
adView.setLayoutParams(params);
rlBanner.addView(adView);
rlBanner.bringChildToFront(rlBanner.findViewById(999));
Thx,因为阅读和帮助导致情况非常糟糕。
答案 0 :(得分:0)
请将adsize =“ MEDIUM_RECTANGLE”更改为“ FLUID”