2016-05-07 4 views
-1

In den letzten fünf Tagen versuche ich Google Admob unter dem WebView zu platzieren. Was mir fehlt, bitte helfe. Falls die Anzeige erscheint, belegt sie das ganze Fenster und blendet alles aus.Problem mit Platz adMob unter Webansicht in LinearLayout

<?xml version="1.0" encoding="utf-8"?> 
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
     xmlns:tools="http://schemas.android.com/tools" 
     xmlns:ads="http://schemas.android.com/apk/res-auto" 
     xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     app:layout_behavior="@string/appbar_scrolling_view_behavior" 
     tools:showIn="@layout/app_bar_main" 
     tools:context=".MainActivity" 
     android:weightSum="1" 
     android:orientation="horizontal"> 


     <com.google.android.gms.ads.AdView 
      android:id="@+id/adView" 
      android:layout_width="match_parent" 
      android:layout_height="75dp" 
      ads:adSize="BANNER" 
      ads:adUnitId="@string/banner_ad_unit_id" 
      android:clickable="false" 
      android:visibility="visible"> 
     </com.google.android.gms.ads.AdView> 

     <ProgressBar 
      android:id="@+id/progressBar" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:layout_gravity="center"/> 

     <WebView 
      android:layout_width="0dp" 
      android:layout_height="match_parent" 
      android:id="@+id/webView" 
      android:layout_weight="0.97" /> 


    </LinearLayout> 

und Java-Code lautet:

AdView mAdView = (AdView) findViewById(R.id.adView); 
     AdRequest adRequest = new AdRequest.Builder().build(); 
     mAdView.loadAd(adRequest); 

Ausgang: enter image description here

+0

verwenden nur adView-Tag unter dem WebView-Tag in xml verwenden sollte ........ – sushildlh

+0

@SushilKumar hat es nicht funktioniert. Bitte helfen Sie –

+0

Ausrichtung in die Vertikale ändern und Schwerkraft in adview hinzufügen ist 0.03 – sushildlh

Antwort

0

Codierung Sie eine RelativeLayout, wie dieser

<RelativeLayout 
xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:ads="http://schemas.android.com/apk/res-auto" 
android:layout_width="match_parent" 
android:layout_height="match_parent"> 
<LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_above="@+id/myId" 
    android:orientation="vertical"> 

    <ProgressBar 
     android:id="@+id/progressBar" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_gravity="center"/> 
    <WebView 
     android:layout_width="0dp" 
     android:layout_height="match_parent" 
     android:id="@+id/webView" 
     android:layout_weight="0.97" /> 

</LinearLayout> 
<com.google.android.gms.ads.AdView 
    android:id="@+id/myId" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_centerHorizontal="true" 
    android:layout_alignParentBottom="true" 
    ads:adSize="BANNER" 
    ads:adUnitId="" /> 
</RelativeLayout> 
1

verwenden xml statt Ihrer xml .....

gibt es 6 bis 7 Änderungen in Ihr xml

<?xml version="1.0" encoding="utf-8"?> 
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
     xmlns:tools="http://schemas.android.com/tools" 
     xmlns:ads="http://schemas.android.com/apk/res-auto" 
     xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     app:layout_behavior="@string/appbar_scrolling_view_behavior" 
     tools:showIn="@layout/app_bar_main" 
     tools:context=".MainActivity" 
     android:weightSum="1" 
     android:orientation="vertical"> 

     <WebView 
      android:layout_width="match_parent" 
      android:layout_height="0dp" 
      android:id="@+id/webView" 
      android:layout_weight="0.90" /> 


     <ProgressBar 
      android:id="@+id/progressBar" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_gravity="center"/> 


     <com.google.android.gms.ads.AdView 
      android:id="@+id/adView" 
      android:layout_width="match_parent" 
      android:layout_weight="0.10" 
      android:layout_height="0dp" 
      ads:adSize="BANNER" 
      ads:adUnitId="@string/banner_ad_unit_id" 
      android:visibility="visible"> 
     </com.google.android.gms.ads.AdView> 


    </LinearLayout> 

genießen ..........