Android 在底部显示广告而不与列表视图重叠

Android 在底部显示广告而不与列表视图重叠,android,android-layout,admob,Android,Android Layout,Admob,我正在从事android项目,我遇到了一个问题,就是在列表视图下方的屏幕底部显示一则广告,而不会造成任何重叠 此时,如果列表视图中有大量项目导致滚动,则应在列表视图下方显示广告,但此时广告位于列表视图顶部,因此,用户无法看到列表视图底部的内容 下面是我的XML布局的副本 <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/

我正在从事android项目,我遇到了一个问题,就是在列表视图下方的屏幕底部显示一则广告,而不会造成任何重叠

此时,如果列表视图中有大量项目导致滚动,则应在列表视图下方显示广告,但此时广告位于列表视图顶部,因此,用户无法看到列表视图底部的内容

下面是我的XML布局的副本

<?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="fill_parent"
    android:background="@color/black"
    android:orientation="vertical" >
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal">
    <TextView android:id="@+id/password_noRecords"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:layout_gravity="center"
        android:text="There are currently\nno saved logins"
        android:textSize="20dp"
        android:textStyle="bold|italic"/>
    <ListView 
        android:id="@android:id/list"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent">
    </ListView>
    <Button android:id="@+id/password_clearSearch" 
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="@string/password_clear_search"
        android:layout_alignParentBottom="true"
        android:visibility="gone"/>
    </LinearLayout>
    <com.google.ads.AdView android:id="@+id/adView"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="center_horizontal"
        android:layout_alignParentBottom="true"
        android:gravity="center_horizontal"
        ads:adUnitId="a14d6125d95c70b"
        ads:adSize="BANNER"
        ads:testDevices="TEST_EMULATOR, 015d1884222bfe01"/>
</RelativeLayout>

我有许多不同的方法,将所有内容都放在相对布局中,而不是另一个线性布局,没有对齐父项bottom=true,但它位于列表视图的顶部,与列表视图顶部的内容重叠


谢谢你能提供的帮助

您可以通过仅使用
线性布局作为基础来解决此问题(去掉
RelativeLayout
),并在
列表视图上使用
android:layout\u weight
属性。例如:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">
    <TextView android:id="@+id/password_noRecords"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:layout_gravity="center"
        android:text="There are currently\nno saved logins"
        android:textSize="20dp"
        android:textStyle="bold|italic"/>
    <ListView 
        android:id="@android:id/list"
        android:layout_width="fill_parent"
        android:layout_height="0dp"
        android:layout_weight="1" />
    <Button android:id="@+id/password_clearSearch" 
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="@string/password_clear_search"
        android:layout_alignParentBottom="true"
        android:visibility="gone"/>
    <com.google.ads.AdView android:id="@+id/adView"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="center_horizontal"
        android:gravity="center_horizontal"
        ads:adUnitId="a14d6125d95c70b"
        ads:adSize="BANNER"
        ads:testDevices="TEST_EMULATOR, 015d1884222bfe01"/>
</LinearLayout>


请注意,
ListView
具有
android:layout\u height=“0dp”
android:layout\u weight=“1”
。这告诉它在
线性布局中放置其他元素后,扩展以填充剩余的任何空间

尝试将
android:id=“@+id/linear\u布局”
添加到线性布局中,并将
android:layou下方=“@id/linear\u布局”
添加到
谢谢您的帮助,这已经困扰了我很多年了