如何使NestedScrollView与AppBar重叠

时间:2019-11-29 10:58:29

标签: android kotlin android-appbarlayout android-nestedscrollview

我想用kotlin在我的Android应用中制作,NestedScrollView与Appbar重叠。 我的XML布局如下:

     <androidx.coordinatorlayout.widget.CoordinatorLayout ......>
        <com.google.android.material.appbar.AppBarLayout
            android:id="@+id/app_bar_layout"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:fitsSystemWindows="true"
            android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

            <com.google.android.material.appbar.CollapsingToolbarLayout
                android:id="@+id/collapsing_toolbar"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:fitsSystemWindows="true"
                app:contentScrim="?attr/colorPrimary"
                app:expandedTitleTextAppearance="@style/TextAppearance.AppCompat.Title"
                app:layout_scrollFlags="scroll|enterAlwaysCollapsed"
                app:titleEnabled="false">

                <ImageView ..... />

                <FrameLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content">

                    <androidx.appcompat.widget.Toolbar
                        android:id="@+id/toolbarProductDetail"
                        android:layout_width="match_parent"
                        android:layout_height="?attr/actionBarSize"
                        app:contentInsetStartWithNavigation="0dp"
                        app:popupTheme="@style/ThemeOverlay.AppCompat.Light" >
                            </androidx.appcompat.widget.Toolbar>
                       </FrameLayout>

            </com.google.android.material.appbar.CollapsingToolbarLayout>

        </com.google.android.material.appbar.AppBarLayout>

        <androidx.core.widget.NestedScrollView
            android:id="@+id/nested_content"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:clipToPadding="false"
            android:layout_marginTop="-25dp"
            app:layout_behavior="@string/appbar_scrolling_view_behavior"
            android:scrollbars="none"
            android:scrollingCache="true">


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

            <androidx.cardview.widget.CardView .....>
   <....>

但是我没有想要的结果,我应该在代码中进行哪些更改以使NestedScrollView与AppBar重叠。

enter image description here

0 个答案:

没有答案