我正在尝试在我的 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(我需要)并像这样设置布局:
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 的最后一项重叠,我看不到它。
任何人都可以帮忙,好吗?
提前致谢。