私は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によって食べられます。
ありがとう