使用 Admob 的 Android Tabview 布局 [英] Android Tabview Layout with Admob

查看:21
本文介绍了使用 Admob 的 Android Tabview 布局的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 android XML,我试图让广告显示在 tabview 的底部,但它们没有显示出来.我想我只是错过了一些非常简单的东西,但我已经研究这个太久了,我希望有人能帮助我.这是 XML:

I have an android XML and I am trying to get the ads to show up at the bottom of a tabview, but they are not showing up. I think I am just missing something very simple, but I have been looking at this for far too long and I hope someone can help me out. Here is the 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:

OK I figured it out. You basically need to use a relative layout to put an ad on the bottom of the screen so I made one after the linear layout. Here is the 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 布局的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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