避免FAB出现在CoordinatorLayout上方

时间:2018-07-01 13:59:20

标签: android android-coordinatorlayout floating-action-button

我正在尝试将图像放置在CoordinatorLayout的顶部,因此它将位于视图的一半。它的工作正常(如上图所示),但是当coordinatorLayout打开到顶部时-图像进入了coordinatorLayout。 任何想法,我怎么能避免这种情况,并保持图像在顶部。 我希望图像进入背景区域。

<?xml version="1.0" encoding="utf-8"?>

<android.support.constraint.ConstraintLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">

        <LinearLayout
            android:id="@+id/backgroundLayout"
            android:layout_width="match_parent"
            android:layout_height="50dp"
            android:background="@color/TRY3"
            android:orientation="vertical"></LinearLayout>

        <android.support.design.widget.CoordinatorLayout
            android:id="@+id/coordinateMainLayout"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:paddingTop="50dp">

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

                <android.support.design.widget.CollapsingToolbarLayout
                    android:id="@+id/collapsingToolBar"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:fitsSystemWindows="true"
                    app:expandedTitleTextAppearance="@android:color/transparent"
                    app:layout_scrollFlags="scroll|exitUntilCollapsed">

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


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

            <android.support.v4.widget.NestedScrollView
                android:id="@+id/innerScrollView"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:clipToPadding="false"
                app:layout_behavior="@string/appbar_scrolling_view_behavior">

                <RelativeLayout
                    android:id="@+id/mainLayout"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:background="@color/B1"
                    android:orientation="vertical">

                    <FrameLayout
                        android:id="@+id/whiteLayout"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:background="@color/B1">

                    </FrameLayout>

                </RelativeLayout>
            </android.support.v4.widget.NestedScrollView>

            <android.support.design.widget.FloatingActionButton
                android:id="@+id/floatingActionButton"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginBottom="70dp"
                android:layout_marginLeft="50dp"
                android:scaleType="center"
                android:src="@drawable/white_plus"
                app:backgroundTint="@color/T103"
                app:fabSize="normal"
                app:layout_anchor="@id/innerScrollView" />
        </android.support.design.widget.CoordinatorLayout>

    </RelativeLayout>

</android.support.constraint.ConstraintLayout>

a enter image description here enter image description here

0 个答案:

没有答案