AdView 会在几秒钟后显示,但它是透明的,并且 listView 占据了整个屏幕。到处找,但无法让 Adview 正常工作。你能看到我做错了什么,所以 ListView 正在为 Adview 腾出空间吗?
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.setContentView(R.layout.activity_with_adview);
}
activity_with_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>