2017-09-21 5 views
0

Ich habe die AdView wie unten angegeben hinzugefügt, aber es zeigt nicht die Anzeige. Ich habe versucht, Relatives Layout (nicht als Root-Layout) zu verwenden, aber das führt zu einer fehlerhaften Funktion der Navigationsleiste. Wie kann ich das lösen?Platzieren von AdView unter DrawerLayout als root-Layout

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

<android.support.v4.widget.DrawerLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:id="@+id/drawer_layout" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    tools:context="com.neupanedinesh.farefindernepal.MainActivity"> 

    <android.support.design.widget.NavigationView 
     android:id="@+id/navigation_view" 
     android:layout_width="wrap_content" 
     android:layout_height="match_parent" 
     android:layout_gravity="start" 
     app:headerLayout="@layout/navigation_header" 
     app:menu="@menu/navigation_menu"/> 


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

     <com.google.android.gms.ads.AdView 
      xmlns:ads="http://schemas.android.com/apk/res-auto" 
      android:id="@+id/adView" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_centerHorizontal="true" 
      android:layout_alignParentBottom="true" 
      ads:adSize="BANNER" 
      ads:adUnitId="ca-app-pub-3940256099942544/6300978111"> 
     </com.google.android.gms.ads.AdView> 


</android.support.v4.widget.DrawerLayout> 

Antwort

0

Setzen Sie Ihre Anzeige Layout innerhalb einer übergeordneten Ansicht

<RelativeLayout 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:background="@android:color/transparent"> 

    <com.google.android.gms.ads.AdView 
     xmlns:ads="http://schemas.android.com/apk/res-auto" 
     android:id="@+id/adView" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_centerHorizontal="true" 
     android:layout_alignParentBottom="true" 
     ads:adSize="BANNER" 
     ads:adUnitId="ca-app-pub-3940256099942544/6300978111"> 
</RelativeLayout> 

und wenn Sie Ihre Navigationsleiste oben auf dem Anzeigenlayout dann Ihr Navigationslayout darunter ein

setzen machen wollen