Admob广告没有显示 - Android

问题描述:

我的广告根本没有显示,我想我已经正确地跟踪了文档,但他们仍然不会显示。该计划基本上是一个Web视图,我希望广告显示在底部。Admob广告没有显示 - Android

继承人我布局文件:

<?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> 

任何想法?

编辑:这是我现在有,但它仍然没有出现很正确:

<?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> 
+0

它看起来你的布局是不正确的。你的webview占用了所有的屏幕。尝试切换webview和adview,并将adview的高度更改为wrap_content而不是fill_parent。 – bhups 2010-09-01 09:03:02

+0

'Admob'中的错误可能是! – 2014-06-29 12:04:28

您的问题是,web视图将采取所有屏幕上的空间,没有空间留下广告。

LinearLayout将按照先到先得的原则分配空间。如果第一次查看通吃的空间第二种观点不会得到任何空间..

我会用一个RelativeLayout,并添加第一个增添了layout_alignParentBottom属性,然后用layout_above="id for the adds"添加web视图。这将确保添加总是在屏幕的底部,即使webview不会占用所有空间,webview将始终高于添加。

+0

感谢您的支持 - 我似乎走在了正确的轨道上,但我仍然没有看到广告 - 我需要更改填充父项吗?我仍然试图让我的头脑围绕Android布局,但感谢迄今为止的巨大帮助。 – user319940 2010-09-01 14:17:04

+0

广告应该是wrap_content作为height和fill_parent的宽度,我假设。 Webview可以保持fill_parent。这应该导致布局的增加尽可能的大,并且webview尽可能大。 – Janusz 2010-09-01 14:29:52

+0

嗯,它仍然没有工作 - 只是为了确认 - 这一切看起来是否正确? (见更新) – user319940 2010-09-01 14:41:43

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads" 
    android:layout_width="fill_parent" android:id="@+id/rltvLayout1" 
    android:layout_height="fill_parent"> 
    <LinearLayout android:id="@+id/linearLayoutwebview" 
     android:layout_height="wrap_content" android:layout_width="wrap_content" 
     android:orientation="vertical"> 
     <WebView android:id="@+id/webView1" 
      android:layout_width="fill_parent" android:layout_height="fill_parent" 
      android:fitsSystemWindows="true" /> 
    </LinearLayout> 
    <LinearLayout android:layout_width="fill_parent" 
     android:id="@+id/ad_layout" android:layout_height="wrap_content" 
     android:gravity="bottom" android:layout_alignParentBottom="true" 
     android:layout_alignBottom="@+id/home_layout"> 
     <com.google.ads.AdView android:layout_width="wrap_content" 
      android:layout_height="wrap_content" ads:adUnitId="put here your ID" 
      ads:adSize="BANNER" android:id="@+id/adView" ads:refreshInterval="60" /> 

    </LinearLayout> 
</RelativeLayout> 

我有同样的问题,我固定它是这样的: 的LinearLayout为主要布局,里面的LinearLayout(为广告)和网页视图,设置WRAP_CONTENT在LinearLayout中的广告,因此,它会首先展示一个广告,然后屏幕的其余部分将成为web视图。我的 例如:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:orientation="vertical" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
> 
    <LinearLayout 
android:id="@+id/addmob" 
xmlns:android="http://schemas.android.com/apk/res/android" 
android:orientation="vertical" 
android:layout_width="wrap_content" 
android:layout_height="wrap_content" 
></LinearLayout> 
<WebView xmlns:android="http://schemas.android.com/apk/res/android" 
android:id="@+id/webview" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent"/> 



</LinearLayout>