Admob 广告未展示 - Android

Admob ads not showing - Android(Admob 广告未展示 - Android)
本文介绍了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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

How to target newer versions in .gitlab-ci.yml using auto devops (java 11 instead of 8 and Android 31 instead of 29)(如何在.gitlab-ci.yml中使用自动开发工具(Java 11而不是8,Android 31而不是29)瞄准较新的版本)
Android + coreLibraryDesugaring: which Java 11 APIs can I expect to work?(Android+core LibraryDesugering:我可以期待哪些Java 11API能够工作?)
How to render something in an if statement React Native(如何在If语句中呈现某些内容Reaction Native)
How can I sync two flatList scroll position in react native(如何在本机Reaction中同步两个平面列表滚动位置)
Using Firebase Firestore in offline only mode(在仅脱机模式下使用Firebase FiRestore)
Crash on Google Play Pre-Launch Report: java.lang.NoSuchMethodError(Google Play发布前崩溃报告:java.lang.NoSuchMethodError)