gpt4 book ai didi

android - 在 XML 中的 TabHost 下面添加 AdView

转载 作者:搜寻专家 更新时间:2023-11-01 08:12:23 25 4
gpt4 key购买 nike

我正在尝试在 TabHost 的正下方获取 AdView。 RelativeLayout 确实允许 android:layout_alignParentBottom="true" 发生这种情况,但是这与 TabHost 内容重叠,并且对于我在每个 Tab 内添加的 ScrollView 也是如此(对于高度较大的任何 View ,这可能会发生够了)

现在,我最接近在屏幕上各自独立的空间中拥有 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>

最佳答案

你应该让标签宿主填充广告 View 之后的剩余空间

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

现在选项卡主机将占用 adview 之后的剩余空间。

关于android - 在 XML 中的 TabHost 下面添加 AdView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8583861/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com