2013-02-26 146 views
0

我想將我的admob廣告放在所有活動的父級底部,但在某些情況下顯示此錯誤。沒有足夠的空間顯示Admob廣告警告

W/Ads(13240): Not enough space to show ad! Wants: <240, 37>, Has: <240, 0> 

XML代碼:

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:background="@color/white" 
    android:orientation="vertical" > 

    <LinearLayout 
     style="@style/padding_title" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:background="@drawable/ic_title" > 

     <TextView 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:layout_gravity="center" 
      android:gravity="center" 
      android:text="Tickets &amp; Cards" 
      android:textColor="@color/white" 
      android:textSize="18.0sp" 
      android:textStyle="bold" /> 
    </LinearLayout> 

    <ScrollView 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" > 
    <More items here> 
     </ScrollView> 

    <include layout="@layout/ad_container" /> 

</LinearLayout> 

而且ad_container.xml是:

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads" 
    android:id="@+id/linear_layout_adv_container" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" > 

    <com.google.ads.AdView 
     android:id="@+id/adView" 
     android:layout_alignParentBottom="true" 
     android:layout_centerHorizontal="true" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     ads:adSize="SMART_BANNER" 
     ads:adUnitId="a15xxxxxxa8088" 
     ads:loadAdOnCreate="true" 
     ads:testDevices="TEST_EMULATOR, TEST_DEVICE_ID" /> 

</RelativeLayout> 

我不知道我錯過了什麼,它爲什麼越來越0高度而不是必需的one.I希望有人指出這個問題。謝謝

回答

0

您的外部佈局有高度match_parent。這意味着它是窗口的大小。它的所有孩子都有高度wrap_content,這意味着每個孩子都適合相應內容的高度。如果之前所有子項的內容高度(您的廣告單元最後都是最後一個)合計高於窗口高度,則廣告單元沒有剩餘空間。

+0

那麼我該怎麼做才能讓它出現在底部? – user818455 2013-02-27 03:49:55

+0

將其設置爲37像素,內容爲wrap_content。 – g00dy 2013-02-27 07:33:26

相關問題