Android 设备上未显示AdMob横幅

Android 设备上未显示AdMob横幅,android,eclipse,android-layout,admob,android-relativelayout,Android,Eclipse,Android Layout,Admob,Android Relativelayout,我正在尝试将AdMob安装到一个应用程序中(以前使用谷歌地图时工作),但现在当我在eclipse的图形布局中查看我的应用程序时,一切看起来都很好。我的AdMob横幅在底部,上面有谷歌的广告,所以我知道它可以工作,但当我把应用程序加载到真实的设备(Galaxy S4)上时,它不会显示出来。我的日志显示广告没有显示,没有刷新广告,但没有其他我希望看到的错误,即没有广告空间等 这是我的布局文件: <RelativeLayout xmlns:android="http://schemas.andr

我正在尝试将AdMob安装到一个应用程序中(以前使用谷歌地图时工作),但现在当我在eclipse的图形布局中查看我的应用程序时,一切看起来都很好。我的AdMob横幅在底部,上面有谷歌的广告,所以我知道它可以工作,但当我把应用程序加载到真实的设备(Galaxy S4)上时,它不会显示出来。我的日志显示广告没有显示,没有刷新广告,但没有其他我希望看到的错误,即没有广告空间等

这是我的布局文件:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:ads="http://schemas.android.com/apk/res-auto"
    android:id="@+id/relativelayout"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentTop="true"
    tools:context=".MainActivity" >

    <EditText
        android:id="@+id/txtText"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="29dp"
        android:alpha="1"
        android:ems="10"
        android:inputType="text" />

    <Button
        android:id="@+id/btnSpeak"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/txtText"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="62dp"
        android:text="@string/btnValue" />

   <Button
        android:id="@+id/btnClear"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/btnSpeak"
        android:layout_centerHorizontal="true"
        android:layout_centerVertical="true"
        android:text="@string/btnClear" />  

   <RelativeLayout
       android:id="@+id/bannerlayout"
       android:layout_width="fill_parent"
       android:layout_height="fill_parent"
       android:gravity="top" >

<com.google.android.gms.ads.AdView  
    android:id="@+id/adView"
    ads:adSize="SMART_BANNER"
    ads:adUnitId="XXXXXXXX/XXXXXXX"
    android:layout_alignParentBottom="true"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"

    />
我只是不明白Eclipse Graphic Layout viewer是如何很好地显示所有内容的,但它没有显示在我的手机上,Logcat只是告诉我广告没有显示其他信息

有什么想法吗


编辑:我的横幅现在显示,但它显示在顶部,即使它应该在底部?

回答您的编辑。由于要将adview添加到相对布局中,而相对布局中的重力设置为“顶部”,因此它就是这样做的。尝试设置:

<RelativeLayout
   android:id="@+id/bannerlayout"
   android:layout_width="fill_parent"
   android:layout_height="fill_parent"
   android:gravity="bottom" >

在“RelativeLayout=(RelativeLayout)findViewById(R.id.bannerlayout);”
横幅布局是我们正在编码的活动的布局还是新的xml?

快速且不干净:将横幅添加到布局中,并将该布局与父布局的底部对齐设置xml中的广告单位和大小应降低。另外,为什么adview在xml中定义,然后在code@A.S.-我会尝试一下,看看会发生什么。@RyPope-如果我从xml中删除adview信息,我会在logcat中得到错误,说需要定义adsize和unit ID,如果我只在xml中创建adview,它不会识别adsize@RyPope是对的,,为什么要定义一个新的AdView?只需调用
AdView-AdView=(AdView)findViewById(R.id.AdView)
Gravity-works。谢谢-虽然我认为我需要从头开始,因为代码是散列的(礼貌地说)
<RelativeLayout
   android:id="@+id/bannerlayout"
   android:layout_width="fill_parent"
   android:layout_height="fill_parent"
   android:gravity="bottom" >