Admob 广告未展示 - Android [英] Admob ads not showing - Android

查看:39
本文介绍了Admob 广告未展示 - Android的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的广告根本没有展示,我认为我正确地遵循了文档,但它们仍然不会展示.该程序基本上是一个 webview,我希望广告显示在底部.

My ads don't display at all, I think I've followed the documentation correctly but they still won't show. The program is basically a webview and I want the ad to display at the bottom.

这是我的布局文件:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
   xmlns:android="http://schemas.android.com/apk/res/android"
   xmlns:myapp="http://schemas.android.com/apk/res/man.utd.headlines"
   android:orientation="vertical"
   android:layout_width="fill_parent"
   android:layout_height="fill_parent">
   <WebView
      android:id="@+id/webview"
      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="fill_parent"
      myapp:backgroundColor="#000000"
      myapp:primaryTextColor="#FFFFFF"
      myapp:secondaryTextColor="#CCCCCC" />
</LinearLayout>

有什么想法吗?

这是我现在所拥有的,但似乎仍然不太正确:

this is what I now have but it still doesn't appear to be quite right:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:myapp="http://schemas.android.com/apk/res/man.utd.headlines"
  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" />
<WebView
    android:id="@+id/webview"
    android:layout_above="@id/ad"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" />
</RelativeLayout>

推荐答案

您的问题是 WebView 将占据屏幕上的所有空间,并且没有空间留给广告.

Your Problem is that the WebView will take all the space on the screen and there is no space left for the ads.

LinearLayout 将按照先到先得的规则分配空间.如果第一个视图占用了所有空间,那么第二个视图将不会获得任何空间..

A LinearLayout will distribute the space on a first come first serve rule. If the first View takes all the space the second view won't get any space..

我会使用 RelativeLayout 并添加首先使用 layout_alignParentBottom 属性添加,然后使用 layout_above="id for the added" 添加 webview.这将确保添加始终位于屏幕底部,即使 webview 目前不会占用所有空间并且 webview 将始终位于添加上方.

I would use a RelativeLayout and add the adds first with a layout_alignParentBottom attribute and then add the webview with a layout_above="id for the adds". This will ensure that the adds are always on the bottom of the screen even if the webview wont take all the space at the moment and the webview will always be above the adds.

这篇关于Admob 广告未展示 - Android的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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