如何获得的广告展示在屏幕下方没有重叠 [英] How to get ad to show at bottom of screen without overlap

查看:205
本文介绍了如何获得的广告展示在屏幕下方没有重叠的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个AdMob的广告横幅,我希望把我的屏幕的底部,并有其他内容调整大小以填充可用空间时,在广告加载。我看到我想要的确切的事情发生当我把广告时的线性布局上,然后让我的内容的高度设置为FILL_PARENT。这是可能实现在反向?当我把我的广告我的内容与FILL_PARENT高度下,它不显示,因为没有足够的空间。我有一个相对布局和底部的余量,以节省为广告空间的解决方案,但我不喜欢黑色的空间是存在的,直到广告加载(如果是这样的话)。任何想法?

I have an admob ad banner which I'd like to put at the bottom of my screen, and have the rest of the content resize to fill the available space when the ad loads in. I see the exact thing I want happen when I put the ad at the top of a linear layout and then have my content's height set to fill_parent. Is this possible to achieve in reverse? When I put my ad underneath my content with the fill_parent height, it doesn't show as there is not enough room. I have a solution with a relative layout and a margin on the bottom to save the space for the ad, but I don't like the black space that is there until the ad loads (if it does at all). Any ideas?

推荐答案

您可以做到这一点通过使用 RelativeLayout的没有做hackish的东西:

You can do that by using RelativeLayout without doing hackish stuff:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent">
    <bla.bla.AdView
            android:id="@+id/ad"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            android:background="#FF0000"/>
    <ListView
            android:id="@android:id/list"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_above="@id/ad"/>
</RelativeLayout>

如果广告不加载一些奇怪的原因,在的ListView 将采取一切可用的空间。另一方面,如果广告确实负载,在的ListView 将不会由广告重叠。

If the ad does not load for some strange reason, the ListView will take all the available space. On the other hand, if the ad does load, the ListView won't be overlapped by the ad.

这篇关于如何获得的广告展示在屏幕下方没有重叠的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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