2016-11-10 53 views
1

我有FloatingActionButton的位置問題。當我從AdMob投放廣告時,我想將廣告放在fab按鈕下方,但是我嘗試的任何方法都無效。電流現在的位置的如何在浮動操作按鈕下添加AdMob

圖片:

Image of current postion

main_activity:

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    xmlns:ads="http://schemas.android.com/apk/res-auto" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:paddingBottom="@dimen/activity_vertical_margin" 
    android:paddingLeft="@dimen/activity_horizontal_margin" 
    android:paddingRight="@dimen/activity_horizontal_margin" 
    android:paddingTop="@dimen/activity_vertical_margin" 
    android:clipToPadding="false"> 

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

<android.support.v7.widget.RecyclerView 
    android:id="@+id/notes_recycler_view" 
    android:scrollbars="vertical" 
    android:layout_alignParentTop="true" 
    android:layout_alignParentLeft="true" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:paddingBottom="80dp" 
    android:clipToPadding="false"/> 

<TextView 
    android:id="@+id/empty_text_view" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:gravity="center" 
    android:visibility="gone" 
    android:text="@string/no_notes"/> 

<android.support.design.widget.FloatingActionButton 
    android:id="@+id/add_button" 
    android:src="@drawable/add" 
    android:layout_alignParentBottom="true" 
    android:layout_alignParentRight="true" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    app:backgroundTint="#e10000" 
    app:fabSize="normal" 
    app:borderWidth="0dp" 
    app:elevation="6dp" 
    app:pressedTranslationZ="12dp" 
    android:onClick="addNote"/> 
</RelativeLayout> 

回答

0

使用layout_above屬性

<?xml version="1.0" encoding="utf-8"?> 
 
<RelativeLayout 
 
    xmlns:android="http://schemas.android.com/apk/res/android" 
 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
 
    xmlns:ads="http://schemas.android.com/apk/res-auto" 
 
    android:layout_width="wrap_content" 
 
    android:layout_height="wrap_content" 
 
    android:paddingBottom="@dimen/activity_vertical_margin" 
 
    android:paddingLeft="@dimen/activity_horizontal_margin" 
 
    android:paddingRight="@dimen/activity_horizontal_margin" 
 
    android:paddingTop="@dimen/activity_vertical_margin" 
 
    android:clipToPadding="false"> 
 

 
<android.support.design.widget.FloatingActionButton 
 
    android:id="@+id/add_button" 
 
    android:src="@drawable/add" 
 
<!--Removed --> 
 
    android:layout_alignParentRight="true" 
 
    android:layout_width="wrap_content" 
 
    android:layout_height="wrap_content" 
 
    app:backgroundTint="#e10000" 
 
    app:fabSize="normal" 
 
    app:borderWidth="0dp" 
 
    app:elevation="6dp" 
 
    app:pressedTranslationZ="12dp" 
 
    android:onClick="addNote" 
 
<!--Added--> 
 
android:layout_above="@+id/adView" 
 
     /> 
 

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

 
<android.support.v7.widget.RecyclerView 
 
    android:id="@+id/notes_recycler_view" 
 
    android:scrollbars="vertical" 
 
    android:layout_alignParentTop="true" 
 
    android:layout_alignParentLeft="true" 
 
    android:layout_width="match_parent" 
 
    android:layout_height="match_parent" 
 
    android:paddingBottom="80dp" 
 
    android:clipToPadding="false"/> 
 

 
<TextView 
 
    android:id="@+id/empty_text_view" 
 
    android:layout_width="match_parent" 
 
    android:layout_height="match_parent" 
 
    android:gravity="center" 
 
    android:visibility="gone" 
 
    android:text="@string/no_notes"/> 
 

 

 
</RelativeLayout>