小编sza*_*man的帖子

浮动动作按钮下的Admob

浮动动作按钮的位置有问题.当我从Admob工厂投放广告时就已经结束了.我想把广告放在fab按钮下,但我尝试的任何方法都不起作用.

广告当前位置的图像

@布局/ activity_layout:

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"
    tools:context=".activities.MainActivity">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fitsSystemWindows="true"
        android:orientation="vertical"
        >

        <android.support.design.widget.AppBarLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:theme="@style/LzTheme.AppBarOverlay">

            <android.support.v7.widget.Toolbar
                android:id="@+id/toolbar"
                android:layout_width="match_parent"
                android:layout_height="?attr/actionBarSize"
                android:background="?attr/colorPrimary"
                app:popupTheme="@style/LzTheme.PopupOverlay"/>

        </android.support.design.widget.AppBarLayout>

        <FrameLayout
            android:id="@+id/drawer_layout"
            xmlns:android="http://schemas.android.com/apk/res/android"
            xmlns:tools="http://schemas.android.com/tools"
            android:layout_width="match_parent"
            android:layout_height="match_parent">

            <include layout="@layout/content_main"/>

            <com.google.android.gms.ads.AdView
                android:id="@+id/ad_view"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_gravity="center|bottom"
                app:adSize="BANNER"
                app:adUnitId="@string/banner_ad_unit_id"/>
        </FrameLayout>
    </LinearLayout>
</android.support.design.widget.CoordinatorLayout>
Run Code Online (Sandbox Code Playgroud)

@布局/ content_main:

<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    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"
    app:layout_behavior="@string/appbar_scrolling_view_behavior"
    tools:context=".activities.MainActivity"
    tools:showIn="@layout/activity_main">

    <FrameLayout
        android:id="@+id/FragmentContainer"
        android:layout_width="match_parent"
        android:layout_height="match_parent"/>

</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)

@布局/片段:

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
             xmlns:app="http://schemas.android.com/apk/res-auto"
             xmlns:tools="http://schemas.android.com/tools"
             android:layout_width="match_parent"
             android:layout_height="match_parent"
             tools:context="com.dsxx.test.fragments.testFragment">

    <android.support.v7.widget.RecyclerView
        android:id="@+id/Recycler" …
Run Code Online (Sandbox Code Playgroud)

android admob android-layout floating-action-button

4
推荐指数
1
解决办法
2699
查看次数