Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/202.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Admob广告未显示-Android_Android_Webview_Admob - Fatal编程技术网

Admob广告未显示-Android

Admob广告未显示-Android,android,webview,admob,Android,Webview,Admob,我的广告根本不显示,我想我已经正确地遵循了文档,但它们仍然不会显示。该计划基本上是一个网络视图,我希望广告显示在底部 这是我的布局文件: <?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.ut

我的广告根本不显示,我想我已经正确地遵循了文档,但它们仍然不会显示。该计划基本上是一个网络视图,我希望广告显示在底部

这是我的布局文件:

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

您的问题是,网络视图将占据屏幕上的所有空间,并且没有空间用于广告

线性布局将按照先到先得的规则分配空间。如果第一个视图占据了所有空间,那么第二个视图将无法获得任何空间

我将使用a,首先添加带有
layout\u alignParentBottom
属性的adds,然后添加带有
layout\u over=“id for the adds”
属性的webview。这将确保添加始终位于屏幕底部,即使此时webview不会占用所有空间,并且webview始终位于添加上方。


<?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(用于广告)和网络视图,在LinearLayout上为广告设置wrap_内容,因此,它将首先显示广告,然后屏幕的其余部分将是网络视图。 我的例子:

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



看起来您的布局不正确。你的网络视图占据了整个屏幕。尝试切换webview和adview,并将adview的高度更改为包装内容,而不是填充父内容。
Admob
中的错误可能是错误!谢谢你-我似乎在正确的轨道上,但我仍然没有看到广告-我需要改变父母吗?我仍在努力了解安卓系统的布局,但感谢到目前为止的巨大帮助。广告应该以高度包装内容,以宽度填充。Webview可以保持为父视图。这将导致一个布局,其中添加的内容尽可能大,网络视图尽可能大。嗯,它似乎仍然不起作用-只是为了确认-所有这些看起来都正确吗?(请参阅更新)应该可以。屏幕底部是否有一个黑条,或者webview占用了所有空间?webview占用了所有空间。在我的admob帐户中,我可以看到这些广告有一个请求,但它们就是没有显示出来(