2014-03-02 90 views
0

我試圖在我的應用程序中顯示Admob廣告,並且我不斷收到以下錯誤「沒有足夠的空間來展示廣告,需要480 X 75像素,但只有400 X 0像素」。我正在使用下面的XML。沒有足夠的空間來展示廣告Android問題

<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" 

        /> 

我試着用各種不同的寬度和高度,但仍然問題仍然存在試驗。任何幫助,將不勝感激。

回答

2

你的第一個問題是你告訴listView消耗所有的高度。你的港灣;「T所示的容器的佈局,但如果切換到的LinearLayout,然後你可以改變它消耗所有剩餘空間來代替:

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

東西也消耗了一些左右填充的。它要麼是未顯示的RelativeLayout容器,要麼是來自s風格。無論如何刪除填充或邊距。

相關問題