簡體   English   中英

如何在浮動操作按鈕下添加AdMob

[英]How to add AdMob under floating action button

我對FloatingActionButton位置有問題。 當我從AdMob廣告時,我想將廣告放在fab按鈕下,但我嘗試的任何方法都不起作用。

當前位置的圖像:

當前位置的圖像

主要活動:

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

使用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> 

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM