Android Admob在ListActivity中是透明的

Android Admob在ListActivity中是透明的,android,admob,adview,Android,Admob,Adview,AdView在几秒钟后显示,但它是透明的,listView占据了整个屏幕。到处都看了,但没有得到建议。你能看到我做错了什么吗,所以ListView为Adview腾出了空间 @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); this.setContentView(R.layout.activity_with_adview); } 活动

AdView在几秒钟后显示,但它是透明的,listView占据了整个屏幕。到处都看了,但没有得到建议。你能看到我做错了什么吗,所以ListView为Adview腾出了空间

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    this.setContentView(R.layout.activity_with_adview);
}
活动\u与\u adview.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <com.google.ads.AdView
        android:id="@+id/adView"
        android:layout_width="wrap_content"
        android:layout_height="50dp"
        android:layout_alignParentBottom="true"
        ads:adSize="BANNER"
        ads:adUnitId="xxxxxxxxxxxxxx"
        ads:loadAdOnCreate="true"
        ads:testDevices="TEST_EMULATOR"
        android:background="@android:color/black" />

    <LinearLayout
        android:id="@+id/home_layout"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_above="@id/adView"
        android:orientation="vertical" >

        <ListView
            android:id="@id/android:list"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="@android:color/black" >
        </ListView>

    </LinearLayout>

</RelativeLayout>
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <com.google.ads.AdView
        android:id="@+id/adView"
        android:layout_width="wrap_content"
        android:layout_height="50dp"
        android:layout_alignParentTop="true"
        ads:adSize="BANNER"
        ads:adUnitId="xxxxxxxxxxxxxx"
        ads:testDevices="TEST_EMULATOR"
        ads:loadAdOnCreate="true"
        android:background="@android:color/black" />

    <FrameLayout
        android:id="@+id/frame_layout"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_below="@id/adView"
        android:orientation="vertical" />

</RelativeLayout> 


我在上面放了一个列表片段。认为这个片段是一个列表

@Override
protected void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);

    this.setContentView(R.layout.activity_with_adview);

    if (TradiesBillingManager.hasPurchasedDiary()) {

        if (getSupportFragmentManager().findFragmentById(android.R.id.content) == null) {
            DiaryFragment list = new DiaryFragment();
            list.setArguments(getIntent().getExtras());
            getSupportFragmentManager().beginTransaction().add(android.R.id.content, list).commit();
        }

    } else {

        DiaryFragment list = new DiaryFragment();
        list.setArguments(getIntent().getExtras());
        getSupportFragmentManager().beginTransaction().replace(R.id.frame_layout, list).commit();
    }

}
活动\u与\u adview.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <com.google.ads.AdView
        android:id="@+id/adView"
        android:layout_width="wrap_content"
        android:layout_height="50dp"
        android:layout_alignParentBottom="true"
        ads:adSize="BANNER"
        ads:adUnitId="xxxxxxxxxxxxxx"
        ads:loadAdOnCreate="true"
        ads:testDevices="TEST_EMULATOR"
        android:background="@android:color/black" />

    <LinearLayout
        android:id="@+id/home_layout"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_above="@id/adView"
        android:orientation="vertical" >

        <ListView
            android:id="@id/android:list"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="@android:color/black" >
        </ListView>

    </LinearLayout>

</RelativeLayout>
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <com.google.ads.AdView
        android:id="@+id/adView"
        android:layout_width="wrap_content"
        android:layout_height="50dp"
        android:layout_alignParentTop="true"
        ads:adSize="BANNER"
        ads:adUnitId="xxxxxxxxxxxxxx"
        ads:testDevices="TEST_EMULATOR"
        ads:loadAdOnCreate="true"
        android:background="@android:color/black" />

    <FrameLayout
        android:id="@+id/frame_layout"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_below="@id/adView"
        android:orientation="vertical" />

</RelativeLayout> 

您使用的是相对布局,您声明的最后一个视图将绘制在其他视图的顶部。如果要将广告放在列表视图上方,则必须在xml文件中的LinearLayout下方声明AdView小部件