2016-09-19 82 views
1

我在现有项目中创建了admob横幅。在相对布局中,我调用了FrameLayout,并在admob横幅的代码下面。但问题在于Admob横幅广告显示在framelayout内容的上方。框架布局下的Admob横幅

我的XML代码如下

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    xmlns:ads="http://schemas.android.com/apk/res-auto"> 

    <include 
     android:id="@+id/toolbar" 
     layout="@layout/toolbar" /> 

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

    <com.google.android.gms.ads.AdView 
     android:id="@+id/adView" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     ads:adSize="SMART_BANNER" 
     ads:adUnitId="@string/banner_home_footer" 
     ads:background="@color/theme_ads" 
     android:layout_alignParentBottom="true"> 
    </com.google.android.gms.ads.AdView> 

</RelativeLayout> 

layout

按照我们不应该把以上内容广告的AdMob政策。我该如何解决这个问题?

回答

3

设置你的FrameLayout上述AdView

<FrameLayout 
    android:id="@+id/fragment_container" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:layout_above="@+id/adView" 
    android:layout_below="@id/toolbar"/> 
+1

谢谢你救了我的一天.... –

0

裹另一个RelativeLayout的;

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
     xmlns:tools="http://schemas.android.com/tools" 
     android:id="@+id/main" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent"> 
     <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:paddingBottom="@dimen/activity_vertical_margin" 
     android:paddingLeft="@dimen/activity_horizontal_margin" 
     android:paddingRight="@dimen/activity_horizontal_margin" 
     android:paddingTop="@dimen/activity_vertical_margin" 
     tools:context=".MainActivity" > 


     <RelativeLayout 
     android:id="@+id/inner_rel" 
      android:layout_width="0dip" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" > 

     <include 
      android:id="@+id/toolbar" 
      layout="@layout/toolbar" /> 

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



    </RelativeLayout> 

</LinearLayout> 
    <com.google.android.gms.ads.AdView 
      android:id="@+id/adView" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      ads:adSize="SMART_BANNER" 
      ads:adUnitId="@string/banner_home_footer" 
      ads:background="@color/theme_ads" 
      android:layout_alignParentBottom="true"> 
     </com.google.android.gms.ads.AdView> 

    </RelativeLayout> 
+0

感谢您的支持..上面的最佳答案... –