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


基础教程推荐
- AdMob 广告未在模拟器中显示 2022-01-01
- libGDX 从精灵或纹理中获取像素颜色 2022-01-01
- iPhone - 获取给定地点/时区的当前日期和时间并将其与同一地点的另一个日期/时间进行比较的正确方法 2022-01-01
- 如何从 logcat 中删除旧数据? 2022-01-01
- NSString intValue 不能用于检索电话号码 2022-01-01
- iOS4 创建后台定时器 2022-01-01
- Android:getLastKnownLocation(LocationManager.NETWORK_PROVIDER 2022-01-01
- Cocos2d iPhone 非矩形精灵触摸检测 2022-01-01
- navigator.geolocation.getCurrentPosition 在 Android 浏览器上 2022-01-01
- 通过重定向链接在 Google Play 中打开应用 2022-01-01