Not enough ad space when add admob in HTML5Webview

柔情痞子 提交于 2019-12-23 05:41:12

问题


now i am working to create an android application that this application use HTML5Webview for play video. I download HTML5webview from this https://code.google.com/p/html5webview/

Now, i want to add admob banner in this application. But, i have a problem when do it. My ads not show because "Not enough ad space". SS Error Message : http://prntscr.com/3lk1t0

In Html5web view, the layout use FrameLayout. I think, the problem is about layout. I search other reference to add admob in FrameLayout, but all reference use RelativeLayout.

How to resolve this problem?

this is my xml layout :

<?xml version="1.0" encoding="utf-8"?>

<FrameLayout android:id="@+id/fullscreen_custom_content"
    android:visibility="gone"
    android:background="@color/black"
    android:layout_width="match_parent"
    android:layout_height="match_parent"

/>
<LinearLayout android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

<FrameLayout android:id="@+id/main_content"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
    />

   <com.google.android.gms.ads.AdView android:id="@+id/adView"
                       android:layout_width="match_parent"
                       android:layout_height="wrap_content"
                       android:paddingLeft="0dp"
                       android:paddingRight="0dp"
                       ads:adSize="BANNER"
                       ads:adUnitId="*****"/>
</LinearLayout></FrameLayout>

and this is my activity class,you can see via dropbox -> Klik for Activity class

My question is, how to add admob if my code like that.? Thanks before.


回答1:


You have several problems with this layout.

  1. You have multiple layout at the outer level. You should only have one. Get rid of the first FrameLayout element.
  2. You finish with a end FrameLayout tag, that matches nothing. This makes the XML structure invalid, there is no way that the Android LayoutManager would have loaded this layout. Remove the final </FrameLayout> tag.
  3. You have specified the height of the LinearLayout as match_parent. This tells the LayoutManager to have that element consume all of the height of its parent. That is why there is no room for the AdView. Change it to wrap_content and add a layout_weight="1" attribute to cause the LayoutManager to expand the element to fill any unused space so that your WebView takes up any space not used by the AdView.

Ie like this:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

   <FrameLayout android:id="@+id/main_content"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1"
    />

   <com.google.android.gms.ads.AdView android:id="@+id/adView"
                       android:layout_width="match_parent"
                       android:layout_height="wrap_content"
                       android:paddingLeft="0dp"
                       android:paddingRight="0dp"
                       ads:adSize="BANNER"
                       ads:adUnitId="*****"/>
</LinearLayout>


来源:https://stackoverflow.com/questions/23812917/not-enough-ad-space-when-add-admob-in-html5webview

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!