2012-02-20 74 views
1

我試圖讓我的tabhost的每個標籤上的Google廣告adview,但它不工作。 如果我將adview放置在main.xml中,我可以在每個標籤上看到adview。 但問題是,視圖(按鈕)顯示在adview上方,所以我不能再看到廣告了?adview在每個標籤(tabhost,admob)

的main.xml:

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

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

     <TabHost 
      xmlns:android="http://schemas.android.com/apk/res/android" 
      android:id="@android:id/tabhost" 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" > 

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

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

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

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

        <include layout="@layout/tab4" /> 
       </FrameLayout> 
      </LinearLayout> 
     </TabHost> 
    </TableLayout> 
</LinearLayout> 

tab1.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/res/com.this.app" 
    android:id="@+id/tab1" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" > 

    <com.google.ads.AdView 
     android:id="@+id/adView" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentBottom="true" 
     ads:adSize="BANNER" 
     ads:adUnitId="xxx" /> 

    <ScrollView 
     android:id="@+id/scrollview1" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:layout_above="@id/adView" > 

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

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

       <TableRow> 

        <Button 
         android:id="@+id/button1" 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:text="1" /> 

        <Button 
         android:id="@+id/button2" 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:text="2" /> 
       </TableRow> 
      </TableLayout> 
     </LinearLayout> 
    </ScrollView> 

</RelativeLayout> 
+0

那裏做ü想看低於或高於tabs.Please廣告指定(在屏幕的底部) – 2012-02-20 18:23:44

+0

@Shahzad下面的選項卡的廣告的位置。 – Bldjef 2012-02-20 18:25:39

回答

0

讓我們試試這個layout.It始終低於框架layout.Hope它有助於。

<?xml version="1.0" encoding="utf-8"?> 
<TabHost xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@android:id/tabhost" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:background="#fff" > 

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

     <FrameLayout 
      android:id="@android:id/tabcontent" 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" 
      android:layout_above="@+id/tv" 
      android:layout_below="@android:id/tabs" > 
     </FrameLayout> 

     <TextView 
      android:id="@+id/tv" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_alignParentBottom="true" 
      android:text="Ads" /> 

     <TabWidget 
      android:id="@android:id/tabs" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:layout_alignLeft="@android:id/tabcontent" 
      android:layout_alignParentTop="true" 
      android:paddingTop="-10dip" > 
     </TabWidget> 
    </RelativeLayout> 

</TabHost> 
+0

嗯,但我需要scrollview滾動和按鈕的其他佈局。否則它不會工作。 – Bldjef 2012-02-20 19:13:43

+0

請儘量使問題清楚。哪種佈局需要??????? – 2012-02-20 19:16:22