Android 如何使用包含MapView且在其下方显示AdMob视图的包装选项卡主机?

Android 如何使用包含MapView且在其下方显示AdMob视图的包装选项卡主机?,android,google-maps,android-mapview,android-tabhost,admob,Android,Google Maps,Android Mapview,Android Tabhost,Admob,我对Android非常陌生(比如2天),但我对其他布局工具包很有经验。我试图在TabHost下面放置一个AdView,似乎我可以让TabWidget或AdView正确显示,但不能同时显示两者 首先,这里是我试图实现的ASCII艺术版本: -------------------------------------------- | Tab 1 | Tab 2 | -----------------------------------------

我对Android非常陌生(比如2天),但我对其他布局工具包很有经验。我试图在TabHost下面放置一个AdView,似乎我可以让TabWidget或AdView正确显示,但不能同时显示两者

首先,这里是我试图实现的ASCII艺术版本:

-------------------------------------------- | Tab 1 | Tab 2 | -------------------------------------------- | MapView when tab 1 is selected | | | | | | | | | | | | | -------------------------------------------- | AdView that stays no matter what tab | -------------------------------------------- -------------------------------------------- |表1 |表2| -------------------------------------------- |选择选项卡1时的地图视图| | | | | | | | | | | | | -------------------------------------------- |无论使用哪种标签,AdView都会保持不变| -------------------------------------------- 如您所见,我正在尝试在TabWidget或FrameLayout之外获取AdView。我希望它在整个tabhost内容之下

以下是添加AdView之前的布局:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 
 xmlns:android="http://schemas.android.com/apk/res/android"
 xmlns:myapp="http://schemas.android.com/apk/res/org.mbs3.android.ufcm"
 android:layout_height="fill_parent"
 android:layout_width="wrap_content"
 >

 <TabHost android:id="@+id/tabhost" android:layout_width="fill_parent"
  android:layout_height="wrap_content">
  <LinearLayout android:layout_width="fill_parent"
   android:id="@+id/home_layout" android:orientation="vertical"
   android:layout_height="fill_parent">

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

    <RelativeLayout android:id="@+id/emptylayout1"
     android:orientation="vertical" android:layout_width="fill_parent"
     android:layout_height="fill_parent" />
    <!--
     programatically added tabs will appear here,
                                        one per activity
    -->
   </FrameLayout>


  </LinearLayout>


 </TabHost>
</RelativeLayout>

现在,我尝试了几个不同的技巧来添加AdView,例如。这是我想到的最好的布局:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
 xmlns:myapp="http://schemas.android.com/apk/res/org.mbs3.android.ufcm"
 android:layout_height="fill_parent" android:layout_width="wrap_content">

 <TabHost android:id="@+id/tabhost" android:layout_width="fill_parent"
  android:layout_height="wrap_content">
  <LinearLayout android:layout_width="fill_parent"
   android:id="@+id/home_layout" android:orientation="vertical"
   android:layout_height="fill_parent">

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

    <RelativeLayout android:id="@+id/emptylayout1"
     android:orientation="vertical" android:layout_width="fill_parent"
     android:layout_height="fill_parent" />
    <!--
     programatically added tabs will appear here, usually one per
     activity
    -->
   </FrameLayout>


  </LinearLayout>



 </TabHost>

 <LinearLayout android:layout_width="fill_parent"
  android:id="@+id/ad_layout" android:layout_height="wrap_content"
  android:gravity="bottom" android:layout_alignParentBottom="true"
  android:layout_alignBottom="@+id/home_layout">

  <com.admob.android.ads.AdView android:id="@+id/ad"
   android:layout_width="fill_parent" android:layout_height="wrap_content"
   myapp:backgroundColor="#000000" myapp:primaryTextColor="#FFFFFF"
   myapp:secondaryTextColor="#CCCCCC"
   myapp:keywords="words" />
 </LinearLayout>

</RelativeLayout>

不幸的是,在该视图中,第一个选项卡中的“地图视图”将缩放控件放在AdView的顶部。有没有我遗漏的简单布局?因为我可以让TabWidget将_内容包装为高度,或者让AdView将_内容包装为高度,但只有当它们位于“@android:id/tabcontent”上方时

选项卡内容下方的任何内容都会被MapView吃掉


谢谢

我不确定这是否是同一件事,但我不得不在活动底部放置一个按钮,并用列表视图填充剩余空间。为此,我做了一些类似的事情:

<RelativeLayout>
    <LinearLayout 
        android:id="@+id/ad_id"
        android:layout_alignParentBottom="true"
        android:layout_height="wrap_content"
        android:layout_width="fill_parent">

       <!-- the ad goes here -->
    </LinearLayout>

    <TabHost
        android:layout_above="@id/ad_id"
        android:layout_height="fill_parent"
        android:layout_width="fill_parent">
      <!-- your view -->
    </TabHost>
</RelativeLayout>

在上半部分之前声明视图的下半部分有点违反直觉:-)