android webview admob not displaying

前端 未结 2 1681

i want to use google adds at bottom of my page.. into the emulator it properly displays the add but in device it doesn\'t
it gives me..

07-20 06:16:2         


        
相关标签:
2条回答
  • 2021-01-17 06:22

    Edit the code as below, add these code

        android:layout_above="@+id/ad_layout"
        android:layout_alignParentTop="true"
    

    Your xml should be like this:

    <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent" android:id="@+id/rltvLayout"
    android:layout_height="fill_parent">
    
    <LinearLayout android:id="@+id/linearLayout1"
        android:layout_height="wrap_content" android:layout_width="wrap_content"
        android:orientation="vertical" android:layout_above="@+id/ad_layout"
        android:layout_alignParentTop="true">
        <WebView android:id="@+id/webViewMakeMp3" 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">
        </LinearLayout>
       </RelativeLayout>
    
    0 讨论(0)
  • 2021-01-17 06:26

    i've use this in xml file

    <?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="here put ID"
                ads:adSize="BANNER" android:id="@+id/adView" ads:refreshInterval="60" />
    
        </LinearLayout>
    </RelativeLayout>
    

    one more point i found is that
    There are some changes to the way Admob works in version 4.1.0
    1) Remove attrs.xml (or if you need it for your own custom attributes, remove the parts related to AdViews).

    2) Change the namespace in your layout from xmlns:ads="http://schemas.android.com/apk/res/com.your.packagename" to xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads" see more...

    0 讨论(0)
提交回复
热议问题