没有足够的空间来展示广告Android问题

时间:2014-03-02 08:12:51

标签: android admob

我正在尝试在我的应用程序中显示Admob广告,并且我不断收到以下错误“没有足够的空间来展示广告。需要480 X 75像素,但只有400 X 0像素”。我使用下面的xml。

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

    <EditText
        android:id="@+id/txtSearch"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="8"
        android:hint="Search Cards..."
        android:inputType="text" />

    <ImageButton
        android:id="@+id/btnSearch"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="2"
        android:src="@drawable/action_search"
        android:scaleType="centerInside"
        style="@android:style/Widget.Holo.Light.Button.Borderless.Small"
         />
</LinearLayout>

<TextView
    android:id="@+id/txtCat"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_below="@+id/lySearch"
    android:layout_marginBottom="5dp"
    android:layout_marginTop="5dp"
    android:gravity="center"
    android:text="List Of Categories"
    android:textColor="#000000"
    android:textSize="14dp"
    android:textStyle="bold" />

<ListView
    android:id="@+id/listView"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_below="@+id/txtCat" />

<Button 
    android:id="@+id/btnAddViewDeck"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_below="@+id/listView"
    android:text="Add/View Decks" />

             <com.google.android.gms.ads.AdView 
                    android:id="@+id/adView"
                     android:layout_width="fill_parent"
                     android:layout_height="wrap_content"
                     ads:adUnitId="xxxxxxxx"
                     ads:adSize="SMART_BANNER"
                     android:layout_below="@+id/btnAddViewDeck" 
                     android:layout_alignParentBottom="true"

                     />

我尝试了各种不同的宽度和高度,但问题仍然存在。任何帮助将不胜感激。

1 个答案:

答案 0 :(得分:2)

你的第一个问题是你告诉listView消耗所有的高度。你没有;没有显示容器的布局,但如果你切换到LinearLayout,那么你可以改变它以消耗所有剩余的空间:

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

某些东西也消耗了一些左右填充。它既可以是未示出的RelativeLayout容器,也可以来自s风格。在任何情况下都要删除填充或边距。

相关问题