在 XML 中的 TabHost 下添加 AdView [英] Adding AdView below TabHost in XML

查看:42
本文介绍了在 XML 中的 TabHost 下添加 AdView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试直接在 TabHost 下方获取 AdView.RelativeLayout 确实允许这种情况发生在 android:layout_alignParentBottom="true" 但是这与 TabHost 内容重叠,并且对于我在每个选项卡内添加的 ScrollView 这样做(这可能会发生在任何高度较大的视图中够了)

I am trying to get an AdView directly below a TabHost. RelativeLayout does allow this to happen with android:layout_alignParentBottom="true" however this overlaps TabHost contents, and does so for the ScrollView's I add inside each Tab (this would probably occur for any views whose height was large enough)

现在,我最接近在屏幕上各自单独的空间中拥有 TabHost 和 AdView 的方法是使用此代码(如下),这使我可以直接在 TabHost 上方拥有广告...如此接近,有什么想法吗?

Right now the closest I can get to having a TabHost and AdView in their own seperate space on the screen is using this code (below), that allows me to have a Ad directly above the TabHost...so close, any ideas?

<代码>

<?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之后的剩余空间

You should make the tab host to fill the remaining space after the adview like

<TabHost
    android:id="@android:id/tabhost"
    android:layout_width="fill_parent"
    android:layout_height="0dip" 
    android:layout_weight="1.0">

现在标签主机将占用广告视图之后的剩余空间.

Now the tab host will take the remaining space after the adview.

这篇关于在 XML 中的 TabHost 下添加 AdView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆