android 4.0中admob广告后面的FAB按钮+
我试图将fab按钮放在adview之上,但在安卓4.0+中,fab按钮go在后面,即使我在上面定义layout_=@+id/ad_视图 这是我的xml代码android 4.0中admob广告后面的FAB按钮+,android,Android,我试图将fab按钮放在adview之上,但在安卓4.0+中,fab按钮go在后面,即使我在上面定义layout_=@+id/ad_视图 这是我的xml代码 <?xml version="1.0" encoding="utf-8"?> <android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://sch
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout 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:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:scrollbars="none"
android:background="#FFFAFAFA"
tools:openDrawer="start">
<android.support.design.widget.CoordinatorLayout
android:id="@+id/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_scrollFlags="scroll|enterAlways">
<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/ThemeOverlay.AppCompat.Light" />
</FrameLayout>
</android.support.design.widget.AppBarLayout>
<FrameLayout
android:id="@+id/frame_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/appbar"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_above="@+id/ad_view"
android:layout_margin="@dimen/fab_margin"
android:src="@android:drawable/ic_dialog_email" />
<com.google.android.gms.ads.AdView
android:id="@+id/ad_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
app:adSize="FULL_WIDTHx50"
app:adUnitId="@string/banner_ad_unit_id" />
</android.support.design.widget.CoordinatorLayout>
<android.support.design.widget.NavigationView
android:id="@+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="#fF312B35"
android:fitsSystemWindows="true"
android:scrollbars="none"
app:headerLayout="@layout/nav_header"
app:itemIconTint="#f3ae1b"
app:itemTextAppearance="@style/TextAppearance.AppCompat.Medium"
app:itemTextColor="@color/White"
app:menu="@menu/menu_drawer"
app:theme="@style/DrawerStyle" />
</android.support.v4.widget.DrawerLayout>
有什么想法吗?相对布局会按照您声明的顺序对视图进行充气。了解更多你可以使用的信息。它将显示视图的渲染方式。用下面的代码替换您的代码,如果有帮助,请接受答案让我知道。谢谢
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom">
<com.google.android.gms.ads.AdView
android:id="@+id/ad_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
app:adSize="FULL_WIDTHx50"
app:adUnitId="@string/banner_ad_unit_id" />
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_above="@+id/ad_view"
android:layout_margin="@dimen/fab_margin"
android:src="@android:drawable/ic_dialog_email" />
</RelativeLayout>
我认为android:layout_over=@+id/ad_视图只适用于RelativeLayout,CMIIW我可以在RelativeLayout中包装fab吗?我想可以,但你必须同时包装fab和AdView,然后你可以使用android:layout_over=@+id/ad_视图,我自己还没有尝试过,但我认为如果我把fab包装在RelativeLayout中,fab和adview都不显示是可行的。你怎么把它包装在RelativeLayout中?