1

我试图将 AdMob 广告添加到我的应用程序中。我想在 a 下添加一个横幅ListView,但没有显示广告,阅读日志看起来没有足够的空间来显示横幅。

08-17 20:11:00.976: E/Ads(7586): 没有足够的空间来展示广告!想要:<320, 50>,拥有:<992, 0>

最后这是我的整个布局:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context=".MainActivity" >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical" >

        <TextView
            android:id="@+id/current_path_textview"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/current_path"
            android:textAppearance="?android:attr/textAppearanceLarge" />
    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical" >

        <ListView
            android:id="@+id/list_of_files"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" >
        </ListView>
    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content" >

        <com.google.ads.AdView
            android:id="@+id/adView"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            ads:adSize="BANNER"
            ads:adUnitId="XXXXXXXXXXXXX"
            ads:loadAdOnCreate="true"
            ads:testDevices="XXXXXXXXXXXXX" />
    </LinearLayout>

</LinearLayout>
4

2 回答 2

4

只需在您的列表视图上定义权重....

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">


        <TextView
            android:id="@+id/current_path_textview"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Ding Chak"
            android:textAppearance="?android:attr/textAppearanceLarge" />


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

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content" >

        <com.google.ads.AdView
            android:id="@+id/adView"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            ads:adSize="BANNER"
            ads:adUnitId="XXXXXXXXXXXXX"
            ads:loadAdOnCreate="true"
            ads:testDevices="XXXXXXXXXXXXX" />
    </LinearLayout>

</LinearLayout>
于 2013-08-17T12:17:37.180 回答
0

只需在 res->values->dimens.xml 中将边距设置为 0dp

<dimen name="activity_horizontal_margin">0dp</dimen>
<dimen name="activity_vertical_margin">0dp</dimen>
于 2014-03-24T17:30:16.540 回答