1

我在从 admob 显示广告的布局上遇到了一些问题。

当应用程序刚启动时,没有广告,一切都很好。布局占据整个屏幕。然后当应用程序可以加载广告(在顶部)时,整个布局将向下移动以显示广告。

如果有广告时整个布局不会向下移动会更好,即如何设置代码以便我可以在横幅位置保留空白背景,这样当没有广告时,它会显示空白背景(和不影响剩余布局),当有广告时,它会替换空白背景的位置,剩余布局仍然固定在原来的位置?

另外,我想问一下代码中的 ads:refreshInterval="15000" 是否意味着在 15 秒内刷新广告?我测试了一下,似乎广告没有按规定刷新?

非常感谢!!

代码如下:

<?xml version="1.0" encoding="utf-8"?>
<TableLayout android:id="@+id/tableLayout" 
   android:layout_width="match_parent" 
   android:layout_height="match_parent" 
   android:stretchColumns="*" 
   android:background="@color/light_green"
   android:orientation="vertical" 
   xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"  
   xmlns:android="http://schemas.android.com/apk/res/android">

  <com.google.ads.AdView 
      android:id="@+id/adView"                         
      android:layout_width="wrap_content"                         
      android:layout_height="wrap_content"                         
      ads:adUnitId="123123123"                         
      ads:adSize="BANNER"      
      ads:refreshInterval="15000"                                           
      ads:loadAdOnCreate="true"/>

    <TableRow
        android:id="@+id/tableRow0"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:paddingRight="8dp" >
    ...
4

1 回答 1

1

在您的 AdView 中,您可以设置android:layout_height="50dp"使容器即使在广告不存在时也能占用空间。

ads:refreshInterval不是有效属性,因此被忽略。刷新率在 AdMob 用户界面中设置,无法在您的应用代码中更改。

于 2012-10-16T17:20:59.023 回答