将admob广告置于列表视图下方

Nam*_*ita 0 xml android admob

我想在屏幕底部放置一个adMob AdView。但是广告在ListView的最后一项上重叠,因此我看不到ListView的最后一项。如果我使用android:layout_below =“ @ + id / list_view”。广告没有加载!

如何将ListView放在AdView的正上方?

 <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical">

        <ListView
            android:id="@+id/list_view"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:scrollingCache="false"
            android:animationCache="false"
            android:smoothScrollbar="true"
            android:stretchMode="columnWidth">
        </ListView>


        <com.google.android.gms.ads.AdView
            android:id="@+id/adView"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@+id/list_view"
            android:layout_alignParentBottom="true"
            android:layout_centerHorizontal="true"
            ads:adSize="SMART_BANNER"
            ads:adUnitId="@string/ads_banner">
        </com.google.android.gms.ads.AdView>


    </RelativeLayout>
Run Code Online (Sandbox Code Playgroud)

Ank*_*ana 5

使您的xml像这样:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <com.google.android.gms.ads.AdView
        xmlns:ads="http://schemas.android.com/apk/res-auto"
        android:id="@+id/adViewCardItem"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        ads:adSize="BANNER"           
        ads:adUnitId="@string/ads_banner">
    </com.google.android.gms.ads.AdView>

    <ListView
        android:id="@+id/list_view"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:animationCache="false"
        android:gravity="center"
        android:scrollingCache="false"
        android:smoothScrollbar="true"
        android:layout_above="@+id/adViewCardItem"
        android:stretchMode="columnWidth" >
    </ListView>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)