本教程将介绍在 XML 中的 TabHost 下添加 AdView的处理方法,这篇教程是从别的地方看到的,然后加了一些国外程序员的疑问与解答,希望能对你有所帮助,好了,下面开始学习吧。
问题描述
我正在尝试直接在 TabHost 下方获取 AdView.RelativeLayout 确实允许这种情况发生在 android:layout_alignParentBottom="true"
但是这与 TabHost 内容重叠,并且对于我在每个选项卡内添加的 ScrollView 这样做(这可能会发生在任何高度较大的视图中够了)
现在,我最接近在屏幕上各自单独的空间中拥有 TabHost 和 AdView 的方法是使用此代码(如下),这使我可以直接在 TabHost 上方拥有广告…如此接近,有什么想法吗?
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
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" >
<com.google.ads.AdView
android:id="@+id/ad"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
ads:adSize="BANNER"
ads:adUnitId="####"
ads:loadAdOnCreate="true"
ads:testDevices="####" />
<TabHost
android:id="@android:id/tabhost"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<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" />
</LinearLayout>
</TabHost>
</LinearLayout>
推荐答案
你应该让tab host填满adview之后的剩余空间
<TabHost
android:id="@android:id/tabhost"
android:layout_width="fill_parent"
android:layout_height="0dip"
android:layout_weight="1.0">
现在标签主机将占用广告视图之后的剩余空间.
好了关于在 XML 中的 TabHost 下添加 AdView的教程就到这里就结束了,希望趣模板源码网找到的这篇技术文章能帮助到大家,更多技术教程可以在站内搜索。