2012-07-05 34 views
0

以下布局用于显示tabcontent上的视图。但是,当admob出现时,framelayout会在前面获取tabwidget。我怎么能设置frameLayout总是上面tabwidget ??或者framelayout下方的tabwidget相同。谢谢android布局get framelayout总是高于tabwidget

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
       xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads" 
       android:orientation="vertical" 
       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" 
         ads:adUnitId="xxx" 
         ads:adSize="SMART_BANNER" 
         ads:testDevices="TEST_EMULATOR, xxx" 
         ads:loadAdOnCreate="true"/> 

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

     <RelativeLayout  
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:id="@+id/mainLayout"> 


     <LinearLayout 
      android:id="@+id/mainLayout" 
      android:orientation="vertical" 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" 
      > 

        <FrameLayout 
         android:id="@android:id/tabcontent" 
         android:layout_width="fill_parent" 
         android:layout_height="0dip" 
         android:layout_weight="1" 
         android:scrollbars="none"> 
        </FrameLayout> 

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

     </LinearLayout>   
    </RelativeLayout> 
</TabHost> 

</LinearLayout> 

enter image description here

回答

0

它应该是这样的...

<TabHost>start 

    <LinearLayout>start 

     <com.google.ads.AdView 
      start 
      end /> 

     <FrameLayout>start 

      <LinearLayout>start 
      <LinearLayout>end 

     </FrameLayout>end 

     <TabWidget>start 
     </TabWidget>end 

    </LinearLayout>end 

</TabHost>end 

如果你想拥有的谷歌添加具有不同选项卡,然后上面的方法是最好的改变,但是如果你不那么就让它这样...

<LinearLayout>start 

    <com.google.ads.AdView 
     start 
     end /> 

    <TabHost>start 

     <LinearLayout>start 

      <FrameLayout>start 

       <LinearLayout>start 
       <LinearLayout>end 

      </FrameLayout>end 

      <TabWidget>start 
      </TabWidget>end 

     </LinearLayout>end 

    </TabHost>end 

</LinearLayout>end 

此外,将标签小部件设置为android:layout_marginBottom =“ - 4dp”以防万一。

1

我看到你的布局两个问题可能会造成这一点。首先,您的TabHost的layout_height不应填写父项。如果您希望它占据布局中的剩余空间(广告未占用的所有内容),请将高度设置为0dip,将layout_weight设置为1,就像您对FrameLayout所做的一样。此外,它看起来像一个嵌套在RelativeLayout中的LinearLayout,其中一个不是必需的。对于你想要的,我会消除RelativeLayout。您还可能想要摆脱TabWidget上的layout_weight属性。将“框架”设置为1表示您希望将其拉伸以填充父级中剩余的所有空间,并且应该为您提供所需的结果。小部件的重量可能是导致重叠的原因。希望这可以帮助。

+0

http://stackoverflow.com/questions/26402748/tabhost-android-viewbadger-badge-issue 看看@MattDavis我面临的问题,我无法解决该错误 – 2014-10-24 19:12:05