Zulkifli Said
Zulkifli Said

Reputation: 631

Not enough ad space when add admob in HTML5Webview

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.

Upvotes: 0

Views: 137

Answers (1)

William
William

Reputation: 20196

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>

Upvotes: 1

Related Questions