2010-12-11 31 views
1

我有一個垂直線性佈局的活動,包含圖像,按鈕,列表視圖和adwhirllayout。所有的都有它們的高度wrap_content,而listview的weight =「1」強制它使用所有剩餘的空間。只要adwhirl不顯示廣告,此工作正常。一旦完成,線性佈局重繪,列表視圖的高度變爲0!此外當listview顯示項目。這些消失。這個adwhirl和剩下的人一樣大一個想法是什麼錯?AdWhirl吃掉所有空間的列表視圖

回答

0

這是我的應用程序的列表視圖之一。它也在屏幕的底部有admob。給它一個。

<LinearLayout 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:layout_weight="1" 
    android:orientation="vertical" > 
    <ListView 
     android:id="@android:id/list" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:layout_weight="1" > 
    </ListView> 
    <TextView 
     android:id="@+id/android:empty" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:text="@string/no_contacts" 
     android:padding="10dp" 
     android:textSize="16sp" 
     android:textStyle="bold" > 
    </TextView> 
</LinearLayout> 

<LinearLayout 
    android:id="@+id/now_playing_loading" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:layout_gravity="bottom" 
    android:gravity="center" > 
    <com.admob.android.ads.AdView 
     android:id="@+id/ad" 
     android:layout_width="fill_parent" 
     android:layout_height="48dp" 
     android:layout_alignParentBottom="true" 
     app:backgroundColor="#000000" 
     app:primaryTextColor="#FFFFFF" 
     app:secondaryTextColor="#CCCCCC" > 
    </com.admob.android.ads.AdView> 
</LinearLayout> 
+0

您明確將高度限制爲48dip。如果我這樣做,它的作品,但我不知道adwhirl廣告總是相同的大小和48dip。他們的示例代碼使用wrap_content。 – Tin 2010-12-11 15:16:28

+1

另一個缺點是,如果沒有廣告,空間不釋放 – Tin 2010-12-11 15:18:32

+0

是真的。但是我想你不能吃蛋糕,也吃。至少我還沒有想出一個辦法呢。 ;) – 2010-12-11 15:29:40