2016-09-28 165 views
1

我創建了一個應用程序並將Admob放入其中。但admob在我的相對佈局中重疊了內容(我認爲是)。Admob重疊佈局內容

我的XML代碼如下

<?xml version="1.0" encoding="utf-8"?> 
<FrameLayout android:id="@+id/main_frag" 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 

    xmlns:app="http://schemas.android.com/apk/res-auto" 
    xmlns:ads="http://schemas.android.com/apk/res-auto"> 

    <!-- 
    As the main content view, the view below consumes the entire 
    space available using match_parent in both dimensions. 
    --> 
    <com.orangegangsters.github.swipyrefreshlayout.library.SwipyRefreshLayout 
     android:id="@+id/activity_main_swipe_refresh_layout" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     app:srl_direction="both"> 

     <android.support.v7.widget.RecyclerView 
      android:id="@+id/listView" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 

      android:divider="@null" 
      android:scrollbars="none"/> 

    </com.orangegangsters.github.swipyrefreshlayout.library.SwipyRefreshLayout> 

    <com.exfileexplorer.filemanager.ui.views.FastScroller 
     android:id="@+id/fastscroll" 
     android:orientation="vertical" 
     android:layout_width="wrap_content" 
     android:layout_gravity="right" 
     android:layout_height="match_parent"/> 
    <RelativeLayout 
     android:id="@+id/nofilelayout" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 

     android:visibility="gone"> 

     <ImageView 
      android:id="@+id/image" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_centerHorizontal="true" 
      android:layout_centerVertical="true" 
      android:src="@drawable/ic_insert_drive_file_white_36dp"/> 

     <TextView 
      style="@android:style/TextAppearance.Medium" 
      android:layout_width="wrap_content" 
      android:textColor="#666666" 
      android:id="@+id/nofiletext" 
      android:layout_marginTop="10dp" 
      android:layout_height="wrap_content" 
      android:layout_below="@id/image" 
      android:fontFamily="sans-serif-medium" 
      android:layout_centerHorizontal="true" 
      android:text="@string/nofiles"/> 

    </RelativeLayout> 
    <com.google.android.gms.ads.AdView 
     android:id="@+id/adView" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     ads:adSize="BANNER" 
     ads:adUnitId="@string/banner_home_footer" /> 
</FrameLayout> 

截圖 enter image description here 我附上截圖它的模樣。按照admob政策它顯然是不道德的。如何在不違反廣告政策的情況下在他們之間放置廣告代碼。

+0

使用'機器人:layout_gravity = 「底」'爲AdView的。 – pRaNaY

+0

它使廣告觸底。我想在不重疊內容的情況下在相同的地方展示廣告。在上面的屏幕截圖中,廣告下面有一些文字。如果沒有廣告,我們可以查看文本..希望你明白我的意思... –

回答

0

把AdMob的塊相對佈局內添加這個機器人:layout_below = 「@ ID/nofiletext」 到AdMob的塊,像這樣:

<com.google.android.gms.ads.AdView 
    android:id="@+id/adView" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    ads:adSize="BANNER" 
    ads:adUnitId="@string/banner_home_footer" 
    android:layout_below="@id/nofiletext"/> 
</RelativeLayout> 
+0

它不工作..現在廣告沒有顯示... –

+0

對不起,所以,嘗試添加此android:layout_alignParentBottom =「true」在你的代碼的第一個版本中,它是如何在 –

+0

之前它沒有改變..再次重疊... –