我有这样的标签布局:
{1} ---- [2] - - - - [3]
代码:
<?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">
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="5dp">
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="5dp"
android:layout_weight="1"/>
<TabWidget
android:id="@android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="0"
android:layout_marginBottom="-4dp"/>
</LinearLayout>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:id="@+id/topLayout"
android:layout_gravity="bottom"
>
<!-- Ad Placeholder -->
<com.google.ads.AdView
android:id="@+id/adView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
ads:adUnitId="MYID"
ads:adSize="BANNER"
ads:loadAdOnCreate="true"
android:layout_gravity="top"
android:layout_alignParentBottom="true"
android:gravity="center_horizontal"
/>
</RelativeLayout>
</TabHost>
我的3个标签位于底部。不过我的广告与他们重叠,有没有办法将广告放在标签下方?
答案 0 :(得分:3)
从AdMob的广告目录示例应用程序中查看此example。它涉及将TabHost和广告包装在RelativeLayout周围,将广告与底部对齐,以及广告上方的TabHost。
您可能希望深入了解示例应用程序 - 它还有其他有关如何在各种布局中使用AdMob的工作示例。