2016-11-10 2 views
1

Ich habe ein Problem mit der Position FloatingActionButton. Wenn ich eine Anzeige aus AdMob setze, möchte ich die Anzeige unter der Fab-Schaltfläche platzieren, aber jede Methode, die ich versuche, funktioniert nicht.Hinzufügen von AdMob unter Floating-Aktion Schaltfläche

Bild der aktuellen Postion:

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> 

Antwort

0

Verwenden layout_above Attribut

<?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>

Verwandte Themen