2

我想直接在TabHost下面獲得AdView。 RelativeLayout確實允許這與android:layout_alignParentBottom="true"發生,但是這與TabHost內容重疊,並且對於我在每個Tab內添加的ScrollView(這可能發生在任何視圖的高度足夠大的情況下)。以XML格式在TabHost下面添加AdView

現在我可以得到最接近的讓TabHost和AdView在屏幕上的自己獨立空間使用這個代碼(下面),這使我可以直接在廣告以上的廣告代碼上使用 ...這麼近,有什麼想法?

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout 
     xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:orientation="vertical" > 

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

    <TabHost 
     android:id="@android:id/tabhost" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" > 

     <LinearLayout 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" 
      android:orientation="vertical" > 

      <TabWidget 
       android:id="@android:id/tabs" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" /> 

      <FrameLayout 
       android:id="@android:id/tabcontent" 
       android:layout_width="fill_parent" 
       android:layout_height="fill_parent" /> 
     </LinearLayout> 
    </TabHost> 

</LinearLayout> 

回答

4

你應該把接頭主機像

<TabHost 
    android:id="@android:id/tabhost" 
    android:layout_width="fill_parent" 
    android:layout_height="0dip" 
    android:layout_weight="1.0"> 

AD瀏覽後,以填補剩餘的空間現在的標籤主機將AD瀏覽後採取的剩餘空間。

+0

謝謝!這一工作,只要我這樣做,並把下面的XML在tabhost的adview :) – skyllo 2011-12-21 08:15:23