使用 Admob 的 Android Tabview 布局

标签 android admob

我有一个 android XML,我试图让广告显示在标签 View 的底部,但它们没有显示。我想我只是遗漏了一些非常简单的东西,但我已经关注这个太久了,我希望有人能帮助我。这是 XML:

<?xml version="1.0" encoding="utf-8"?>

<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:myapp="http://schemas.android.com/apk/res/com.Vdrop"
    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">
        <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"
            android:padding="5dp" />
            <com.admob.android.ads.AdView     
           android:id="@+id/ad" 
           android:layout_width="fill_parent" 
           android:layout_height="wrap_content"
           android:gravity="bottom"
           myapp:backgroundColor="#000000"
           myapp:primaryTextColor="#FFFFFF"
           myapp:secondaryTextColor="#CCCCCC"
  />
    </LinearLayout>
</TabHost>

有什么想法吗?

最佳答案

好吧,我明白了。你基本上需要使用相对布局将广告放在屏幕底部,所以我在线性布局之后做了一个。这是 XML:

<?xml version="1.0" encoding="utf-8"?>

<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:myapp="http://schemas.android.com/apk/res/com.Vdrop"
    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">
        <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"
            android:padding="5dp" />
    </LinearLayout>
    <RelativeLayout
        android:orientation="vertical"
        android:layout_width="fill_parent" 
        android:layout_height="fill_parent">
    <com.admob.android.ads.AdView     
           android:id="@+id/ad" 
           android:layout_width="fill_parent" 
           android:layout_height="wrap_content"
           android:layout_alignParentBottom="true"
           myapp:backgroundColor="#000000"
           myapp:primaryTextColor="#FFFFFF"
           myapp:secondaryTextColor="#CCCCCC"
  />
  </RelativeLayout>
</TabHost>

关于使用 Admob 的 Android Tabview 布局,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3576117/

相关文章:

java - 安卓媒体播放器

android - 在 Eclipse 中构建 Android 项目时构建 C++ 共享对象

android - 如何在安卓模拟器中安装Skype?

android - 如何正确安装 admob,在某些测试手机上不显示

android - Admob 奖励视频广告不适用于测试设备

android - AdMob 广告停止在一个应用中展示

php - Phonegap php header 重定向在 android 中不起作用

android - 使用 Admob 强制关闭

ios - AdMob + 显示内容缓慢 + Google DFP

android - Admob 横幅窃取焦点