Android AdMob AdView RelativeLayout中的重叠列表视图

Android AdMob AdView RelativeLayout中的重叠列表视图,android,admob,Android,Admob,我正在尝试在我的Android应用程序中显示AdView。 我有一个这样的亲戚: <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/mainLayout" android:layout_width="match_parent" an

我正在尝试在我的Android应用程序中显示AdView。 我有一个这样的亲戚:

 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/mainLayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity" >

    <ListView
        android:id="@+id/listaFicheros"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:visibility="visible"
        tools:listitem="@android:layout/simple_list_item_2" >
    </ListView>

    <TextView
        android:id="@+id/sinFicheros"
        style="@android:style/TextAppearance.Large"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_alignParentTop="true"
        android:gravity="center"
        android:clickable="true"
        android:text="@string/SinFicheros" >
    </TextView>

</RelativeLayout>
adView = new AdView(this, AdSize.BANNER, ID_EDITOR);

ListView listaFicheros = (ListView)findViewById(R.id.listaFicheros);

RelativeLayout.LayoutParams adLayoutParams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
adLayoutParams.addRule(RelativeLayout.ALIGN_BOTTOM, listaFicheros.getId());
adView.setLayoutParams(adLayoutParams);

RelativeLayout.LayoutParams listaLayoutParams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT);
listaLayoutParams.addRule(RelativeLayout.ABOVE, adView.getId());
listaFicheros.setLayoutParams(listaLayoutParams);

RelativeLayout layout = (RelativeLayout)findViewById(R.id.mainLayout);
layout.addView(adView);
Adview在屏幕底部正确显示,但我的问题是Adview与ListView的最后一项重叠,我看不到它

有人能帮忙吗


提前感谢。

您已将listaFicheros的布局参数设置为匹配父视图、匹配父视图(即接管父视图的整个视图,并且您已告知AdView将其底部与listaFicheros的底部对齐。这就是为什么会有重叠


有几种方法可以解决此问题。建议您将AdView更改为ALIGN\u PARENT\u BOTTOM。强烈建议您使用xml构建AdView,因为它可以帮助您更清楚地思考布局。

非常感谢您的回答。最后,我转到LinearLayout,一切都正常。即使如此,我也无法将AdView添加到xml中因为是一个库项目,我想制作两个版本的应用程序(其中一个没有广告),所以我只在免费版本中添加AdView:)你仍然可以通过XML添加AdView,然后将其隐藏在没有广告的版本中。当然,但是应用程序代码会更清楚地以友好方式添加它(我正在以这种方式检查应用程序的版本),或者我就是这么想的;)。无论如何,谢谢你的帮助。