繁体   English   中英

ListView阻止Admob广告

[英]ListView blocking Admob Ad

我有以下与ListActivity对应的XML文件:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
    android:id="@+id/classview"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >

    <com.google.ads.AdView
        android:id="@+id/adView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        ads:adSize="BANNER"
        ads:adUnitId="xxxx" >
    </com.google.ads.AdView>

    <ListView
        android:id="@android:id/list"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent" />

</LinearLayout>

我从ListActivity中调用此Java代码:

public void setupAd(){
    AdRequest adRequest = new AdRequest();
    adRequest.addTestDevice("xxxx");
    AdView adView = (AdView) findViewById(R.id.adView);
    adView.loadAd(adRequest);


}

当我查看XML文件的图形布局时,似乎广告横幅恰好位于ListView的顶部。 但是,当我运行实际的应用程序时,ListView似乎占据了整个屏幕,可能会阻塞广告。 有人知道怎么了吗?

问题是您的ListView具有layout_height =“ fill_parent”。

<ListView
    android:id="@android:id/list"
    android:layout_width="match_parent"
    android:layout_height="wrap_content" 
    android:layout_weight="1" 
 />

而是让它wrap_content并使用layout_weight =“ 1”告诉它消耗任何未使用的空间。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM