在 SlidingUpPanel 上方制作 NavigationDrawer

Make NavigationDrawer above SlidingUpPanel

我想在向上滑动面板上方制作导航抽屉。 我用这个 https://github.com/umano/AndroidSlidingUpPanel

<com.sothree.slidinguppanel.SlidingUpPanelLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:sothree="http://schemas.android.com/apk/res-auto"
android:id="@+id/suplSurveys"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="bottom"
sothree:umanoScrollableView="@+id/vpPlace"
sothree:umanoPanelHeight="68dp"
sothree:umanoParallaxOffset="100dp"
sothree:umanoDragView="@+id/dragView"
sothree:umanoOverlay="true">

<FrameLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">
    <android.support.v4.widget.DrawerLayout
        android:id="@+id/drawer_layout"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

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

            <fragment
                android:id="@+id/map"
                android:name="com.google.android.gms.maps.SupportMapFragment"
                android:layout_width="match_parent"
                android:layout_height="match_parent" />

            <android.support.v7.widget.Toolbar
                android:id="@+id/toolbar"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:background="#006df0"
                app:titleTextColor="@color/colorBackGrey"
                android:elevation="20dp"
                app:layout_scrollFlags="scroll|enterAlways"
                app:popupTheme="@style/ThemeOverlay.AppCompat.Light"/>

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_gravity="top|end"
                android:layout_marginTop="65dp"
                android:orientation="vertical">

                <android.support.design.widget.FloatingActionButton
                    android:id="@+id/fab_my_location"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="top|end"
                    android:layout_marginTop="10dp"
                    android:layout_marginEnd="15dp"
                    app:backgroundTint="@color/jet"
                    app:fabSize="normal"
                    app:srcCompat="@drawable/ic_my_location" />

            </LinearLayout>

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

                <FrameLayout
                    android:layout_width="match_parent"
                    android:layout_height="60dp"
                    android:layout_marginBottom="65dp"
                    android:paddingLeft="80dp"
                    android:paddingRight="80dp"
                    android:layout_gravity="center">

                    <com.dd.morphingbutton.impl.IndeterminateProgressButton
                        android:id="@+id/add_new_location"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:gravity="center_horizontal"
                        android:fontFamily="@font/pt_mono"
                        android:layout_gravity="center_horizontal"
                        android:textSize="18sp"
                        android:textColor="@color/colorBackGrey"
                        android:text="ADD"/>

                </FrameLayout>

            </LinearLayout>

        </FrameLayout>

        <android.support.design.widget.NavigationView
            android:id="@+id/nvView"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:layout_gravity="start"
            app:headerLayout="@layout/navdraw_header"
            app:menu="@menu/drawer_view" />

    </android.support.v4.widget.DrawerLayout>
</FrameLayout>

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="400dp"
    android:paddingRight="10dp"
    android:paddingLeft="10dp"
    android:background="@drawable/border"
    android:orientation="vertical"
    android:focusable="false"
    android:id="@+id/dragView">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="68dp"
        android:orientation="vertical">
        <TextView
            android:layout_width="48dp"
            android:layout_height="2dp"
            android:layout_marginTop="5dp"
            android:gravity="center"
            android:layout_gravity="center"
            android:background="#dddddd" />

        <TextView
            android:layout_width="48dp"
            android:layout_marginTop="5dp"
            android:layout_height="2dp"
            android:gravity="center"
            android:layout_gravity="center"
            android:background="#dddddd" />

        <TextView android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:textSize="14sp"
            android:fontFamily="@font/pt_mono"
            android:textStyle="bold"
            android:text="DAFTAR LOKASI SURVEY"
            android:textColor="@color/colorAccent"
            android:gravity="center_vertical"
            android:paddingLeft="10dp"/>

    </LinearLayout>

    <ProgressBar
        style="?android:attr/progressBarStyleSmall"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center_horizontal"
        android:id="@+id/pbLoad"
        android:gravity="center"
        android:layout_margin="15dp" />

    <android.support.v7.widget.RecyclerView
        android:id="@+id/vpPlace"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1" />

</LinearLayout></com.sothree.slidinguppanel.SlidingUpPanelLayout>

这是我的布局代码

所以我不明白生二胎是什么意思 所以我不明白生二胎是什么意思 所以我不明白生二胎是什么意思 所以我不明白生二胎是什么意思 所以我不明白生二胎是什么意思

这应该是一个简单的修复,我看不到你的布局 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://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"
    tools:openDrawer="start">
    <android.support.design.widget.CoordinatorLayout
        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.support.design.widget.AppBarLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:theme="@style/AppTheme.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/AppTheme.PopupOverlay" />
        </android.support.design.widget.AppBarLayout>
        <LinearLayout
            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"
            app:layout_behavior="@string/appbar_scrolling_view_behavior"
            tools:context=".MainActivity"
            tools:showIn="@layout/app_bar_main">
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Hello World!"
                app:layout_constraintBottom_toBottomOf="parent"
                app:layout_constraintLeft_toLeftOf="parent"
                app:layout_constraintRight_toRightOf="parent"
                app:layout_constraintTop_toTopOf="parent" />
        </LinearLayout>
    </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:fitsSystemWindows="true"
        app:menu="@menu/activity_main_drawer" />
</android.support.v4.widget.DrawerLayout>

显示如下内容(与您的类似):

您需要将整个屏幕包裹在另一种布局中(可能是垂直的线性布局)。您将需要提取工具栏并将其带到 outer/top 最位置,如下所示:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:layout_height="match_parent"
    android:layout_width="match_parent"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical">
    <android.support.design.widget.AppBarLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:theme="@style/AppTheme.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/AppTheme.PopupOverlay" />
    </android.support.design.widget.AppBarLayout>
    <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"
        tools:openDrawer="start">
        <android.support.design.widget.CoordinatorLayout
            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">
            <LinearLayout
                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"
                app:layout_behavior="@string/appbar_scrolling_view_behavior"
                tools:context=".MainActivity"
                tools:showIn="@layout/app_bar_main">
                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="Hello World!"
                    app:layout_constraintBottom_toBottomOf="parent"
                    app:layout_constraintLeft_toLeftOf="parent"
                    app:layout_constraintRight_toRightOf="parent"
                    app:layout_constraintTop_toTopOf="parent" />
            </LinearLayout>
        </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:fitsSystemWindows="true"
            app:menu="@menu/activity_main_drawer" />
    </android.support.v4.widget.DrawerLayout>
</LinearLayout>

这将满足您的需求 - 工具栏现在将保留在顶部并显示为:

让我知道这是否有帮助 - 请记住,我已经做了一些假设,因为我还没有看到任何代码。

    <?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/drawer_layout"
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:sothree="http://schemas.android.com/apk/res-auto">

    <com.sothree.slidinguppanel.SlidingUpPanelLayout
        android:id="@+id/suplSurveys"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:gravity="bottom"
        sothree:umanoScrollableView="@+id/vpPlace"
        sothree:umanoPanelHeight="68dp"
        sothree:umanoParallaxOffset="100dp"
        sothree:umanoDragView="@+id/dragView"
        sothree:umanoOverlay="true">

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

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

                    <fragment
                        android:id="@+id/map"
                        android:name="com.google.android.gms.maps.SupportMapFragment"
                        android:layout_width="match_parent"
                        android:layout_height="match_parent" />

                    <android.support.v7.widget.Toolbar
                        android:id="@+id/toolbar"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:background="#006df0"
                        app:titleTextColor="@color/colorBackGrey"
                        android:elevation="20dp"
                        app:layout_scrollFlags="scroll|enterAlways"
                        app:popupTheme="@style/ThemeOverlay.AppCompat.Light"/>

                    <LinearLayout
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_gravity="top|end"
                        android:layout_marginTop="65dp"
                        android:orientation="vertical">

                        <android.support.design.widget.FloatingActionButton
                            android:id="@+id/fab_my_location"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_gravity="top|end"
                            android:layout_marginTop="10dp"
                            android:layout_marginEnd="15dp"
                            app:backgroundTint="@color/jet"
                            app:fabSize="normal"
                            app:srcCompat="@drawable/ic_my_location" />

                    </LinearLayout>

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

                        <FrameLayout
                            android:layout_width="match_parent"
                            android:layout_height="60dp"
                            android:layout_marginBottom="65dp"
                            android:paddingLeft="80dp"
                            android:paddingRight="80dp"
                            android:layout_gravity="center">

                            <com.dd.morphingbutton.impl.IndeterminateProgressButton
                                android:id="@+id/add_new_location"
                                android:layout_width="match_parent"
                                android:layout_height="wrap_content"
                                android:gravity="center_horizontal"
                                android:fontFamily="@font/pt_mono"
                                android:layout_gravity="center_horizontal"
                                android:textSize="18sp"
                                android:textColor="@color/colorBackGrey"
                                android:text="ADD"/>

                        </FrameLayout>

                    </LinearLayout>

                </FrameLayout>

            <!--</android.support.v4.widget.DrawerLayout>-->
        </FrameLayout>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="400dp"
            android:paddingRight="10dp"
            android:paddingLeft="10dp"
            android:background="@drawable/border"
            android:orientation="vertical"
            android:focusable="false"
            android:id="@+id/dragView">

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="68dp"
                android:orientation="vertical">
                <TextView
                    android:layout_width="48dp"
                    android:layout_height="2dp"
                    android:layout_marginTop="5dp"
                    android:gravity="center"
                    android:layout_gravity="center"
                    android:background="#dddddd" />

                <TextView
                    android:layout_width="48dp"
                    android:layout_marginTop="5dp"
                    android:layout_height="2dp"
                    android:gravity="center"
                    android:layout_gravity="center"
                    android:background="#dddddd" />

                <TextView android:layout_width="wrap_content"
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:textSize="14sp"
                    android:fontFamily="@font/pt_mono"
                    android:textStyle="bold"
                    android:text="DAFTAR LOKASI SURVEY"
                    android:textColor="@color/colorAccent"
                    android:gravity="center_vertical"
                    android:paddingLeft="10dp"/>

            </LinearLayout>

            <ProgressBar
                style="?android:attr/progressBarStyleSmall"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center_horizontal"
                android:id="@+id/pbLoad"
                android:gravity="center"
                android:layout_margin="15dp" />

            <android.support.v7.widget.RecyclerView
                android:id="@+id/vpPlace"
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_weight="1" />

        </LinearLayout>

    </com.sothree.slidinguppanel.SlidingUpPanelLayout>

    <android.support.design.widget.NavigationView
        android:id="@+id/nvView"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_gravity="start"
        app:headerLayout="@layout/navdraw_header"
        app:menu="@menu/drawer_view" />


</android.support.v4.widget.DrawerLayout>