Android 在安卓4.4或更低版本上抢占先机

Android 在安卓4.4或更低版本上抢占先机,android,android-layout,android-recyclerview,android-design-library,Android,Android Layout,Android Recyclerview,Android Design Library,mi的问题是,fab_bar按钮位于RecyclerView的后面。这只发生在Android 4.4或更低版本中,在最新的Android版本中我没有任何问题 我没有足够的声誉来发布图片,因此我离开了链接: 是否有任何解决方案,或者是一个bug <?xml version="1.0" encoding="utf-8"?> <android.support.design.widget.CoordinatorLayout xmlns:android="http://sch

mi的问题是,fab_bar按钮位于RecyclerView的后面。这只发生在Android 4.4或更低版本中,在最新的Android版本中我没有任何问题

我没有足够的声誉来发布图片,因此我离开了链接:

是否有任何解决方案,或者是一个bug

<?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"
    android:id="@+id/main_content"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true">

    <android.support.design.widget.AppBarLayout
        android:id="@+id/appbar"
        android:layout_width="match_parent"
        android:fitsSystemWindows="true"
        android:layout_height="@dimen/detail_backdrop_height"
        android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

        <android.support.design.widget.CollapsingToolbarLayout
            android:id="@+id/collapsing_toolbar"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            app:layout_scrollFlags="scroll|exitUntilCollapsed"
            app:contentScrim="?attr/colorPrimary"
            android:fitsSystemWindows="true"
            android:elevation="@dimen/toolbar_shadow_elevation">

            <android.support.v7.widget.Toolbar
                android:id="@+id/toolbar"
                android:layout_width="match_parent"
                android:layout_height="?attr/actionBarSize"
                app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
                app:layout_collapseMode="pin" />

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

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

    <android.support.design.widget.FloatingActionButton
        android:layout_height="wrap_content"
        android:id="@+id/fab_bar"
        android:layout_width="wrap_content"
        app:layout_anchor="@id/appbar"
        app:layout_anchorGravity="bottom|right|end"
        android:src="@drawable/ic_action_edit_light"
        android:layout_margin="@dimen/fab_margin"
        android:clickable="true"
        android:elevation="@dimen/fab_bar_shadow_elevation"/>

    <android.support.v7.widget.RecyclerView
        android:id="@+id/recycler_atrib_list"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layout_behavior="@string/appbar_scrolling_view_behavior"/>

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

试试这个:

<?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"
    android:id="@+id/main_content"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true">

    <android.support.design.widget.AppBarLayout
        android:id="@+id/appbar"
        android:layout_width="match_parent"
        android:fitsSystemWindows="true"
        android:layout_height="@dimen/detail_backdrop_height"
        android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

        <android.support.design.widget.CollapsingToolbarLayout
            android:id="@+id/collapsing_toolbar"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            app:layout_scrollFlags="scroll|exitUntilCollapsed"
            app:contentScrim="?attr/colorPrimary"
            android:fitsSystemWindows="true"
            android:elevation="@dimen/toolbar_shadow_elevation">

            <android.support.v7.widget.Toolbar
                android:id="@+id/toolbar"
                android:layout_width="match_parent"
                android:layout_height="?attr/actionBarSize"
                app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
                app:layout_collapseMode="pin" />

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

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

    <android.support.v7.widget.RecyclerView
        android:id="@+id/recycler_atrib_list"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layout_behavior="@string/appbar_scrolling_view_behavior"/>

    <android.support.design.widget.FloatingActionButton
        android:layout_height="wrap_content"
        android:id="@+id/fab_bar"
        android:layout_width="wrap_content"
        app:layout_anchor="@id/appbar"
        app:layout_anchorGravity="bottom|right|end"
        android:src="@drawable/ic_action_edit_light"
        android:layout_margin="@dimen/fab_margin"
        android:clickable="true"
        android:elevation="@dimen/fab_bar_shadow_elevation"/>

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


在您的代码中,
FAB
位于
RecyclerView
之前,因此
RecyclerView
覆盖
FAB

非常感谢!我花了几天时间仔细考虑这一胡说八道。我认为申报顺序在布局中并不重要。。。