AdMob广告不显示

时间:2014-03-11 12:39:44

标签: admob google-play-services

我的xml文件

<LinearLayout 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/quadro"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"`enter code here`
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".HomeActivity" >
<LinearLayout
    android:id="@+id/linha01"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:gravity="center"
    android:orientation="horizontal" >
</LinearLayout>

<LinearLayout
    android:id="@+id/linha02"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:gravity="center"
    android:orientation="horizontal" >
</LinearLayout>

<LinearLayout
    android:id="@+id/linha03"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:gravity="center"
    android:orientation="horizontal" >
</LinearLayout>

<LinearLayout
    android:id="@+id/linha04"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:gravity="center"
    android:orientation="horizontal" >
</LinearLayout>

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:gravity="center" >
</LinearLayout>

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:gravity="center|left" >

</LinearLayout>

<RelativeLayout
    android:id="@+id/linhaAd"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="horizontal" >

    <com.google.android.gms.ads.AdView
        android:id="@+id/adView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        ads:adSize="BANNER"
        ads:adUnitId="ca-app-pub-xxxxxx" />
</RelativeLayout>

我的代码

protected void onCreate(Bundle savedInstanceState) 
{
    /*...
     *Code
     *...*/

    adView = (AdView)this.findViewById(R.id.adView);
    AdRequest adRequest = new AdRequest.Builder()
    .addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
    .build();

    adView.loadAd(adRequest);
}

清单xml

<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
...

<meta-data android:name="com.google.android.gms.version"
       android:value="@integer/google_play_services_version" />
...

<activity android:name="com.google.android.gms.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>

当我更改广告的背景时,它会显示黑色背景,但没有任何文字.adView甚至会在AdMob中创建展示次数,但不显示。我不知道可以是什么

1 个答案:

答案 0 :(得分:0)

摆脱RelativeLayout。没有必要,你已经设置它消耗其父级的所有高度,这几乎肯定不是你想要的。