6

私はAndroidに非常に慣れていません(2日など)が、他のレイアウトツールキットの経験があります。AdViewをTabHostの下に配置しようとしていますが、TabWidgetまたはAdViewのいずれかを正しく表示できるようですが、両方を表示することはできません。

まず、これが私が達成しようとしていることのASCIIアートバージョンです:

--------------------------------------------
| タブ1| タブ2|
--------------------------------------------
| タブ1が選択されている場合のMapView|
| |
| |
| |
| |
| |
| |
--------------------------------------------
| どのタブに関係なく残るAdView|
--------------------------------------------

ご覧のとおり、私はAdViewをTabWidgetまたはFrameLayoutの外に取得しようとしています。タブホストのコンテンツ全体の下に配置したいと思います。

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>

ここで、 http://www.spencerelliott.ca/blogs/blog-android-menuなど、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>

残念ながら、その1つでは、最初のタブのMapViewがズームコントロールをAdViewの上に配置します。私が見逃しているいくつかの単純なレイアウトはありますか?Cuz私はTabWidgetを高さのwrap_contentに、またはAdViewを高さのwrap_contentに取得できますが、それらが「@ android:id/tabcontent」より上にある場合に限ります。

タブコンテンツの下にあるものはすべて、MapViewによって食べられます。

ありがとう

4

1 に答える 1

5

同じかどうかはわかりませんが、アクティビティの下部にボタンを配置し、残りのスペースをListViewで埋める必要がありました。これを行うために、私は次のようなことをしました。

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

ビューの下部を上部の前に宣言するのは少し直感に反します:-)

于 2010-09-18T14:12:57.923 に答える