Admob广告横幅未显示所有设备

时间:2016-02-04 05:43:06

标签: android xml

我在我的应用程序中使用广告横幅。它在xml布局上显示正确但我在设备上运行此代码,然后它没有显示480 * 800的恢复设备,但在720 * 1280设备中正确显示。

我应该添加什么代码,以便支持所有屏幕重建。

请提前帮助谢谢。

代码

             <RelativeLayout
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:gravity="bottom">

              <com.google.android.gms.ads.AdView
             android:id="@+id/adView"
             android:layout_width="fill_parent"
             android:layout_height="wrap_content"
             android:layout_centerHorizontal="true"
             android:layout_alignParentBottom="true"
             android:layout_marginLeft="10dp"
             android:layout_marginRight="10dp"
             ads:adSize="BANNER"
             ads:adUnitId="banner_ad_unit_id">
         </com.google.android.gms.ads.AdView>
    </RelativeLayout>`

2 个答案:

答案 0 :(得分:1)

删除

android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"

如果AdView无法获得整个屏幕宽度,则无法加载。

您可以参考this answer

答案 1 :(得分:1)

如果AdView的宽度小于320dp,则不会显示任何广告。您可以删除边距值,或根据屏幕宽度更改这些值,以确保最小宽度。

相关问题