Android 禁用滚动时的工具栏折叠

Android 禁用滚动时的工具栏折叠,android,scroll,toolbar,Android,Scroll,Toolbar,我有一个带有工具栏的活动,当我滚动滚动滚动视图时,它会隐藏,但是,内容没有手机屏幕大多少,所以我想禁用工具栏的隐藏,因为它没有任何意义。我该怎么做 <ScrollView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/svCreateAdvert" android:layout_width="match_parent"

我有一个带有工具栏的活动,当我滚动滚动滚动视图时,它会隐藏,但是,内容没有手机屏幕大多少,所以我想禁用工具栏的隐藏,因为它没有任何意义。我该怎么做

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
            android:id="@+id/svCreateAdvert"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:fillViewport="true">

    <RelativeLayout
        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:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@color/grey"
        android:orientation="vertical"
        tools:context=".CreateAdvert">

        <LinearLayout
            android:id="@+id/create_advert_container_toolbar"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical">

            <android.support.v7.widget.Toolbar
                android:id="@+id/createAdvertToolbar"
                android:layout_width="match_parent"
                android:layout_height="?attr/actionBarSize"
                android:background="?attr/colorPrimary"
                android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"

                app:popupTheme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"/>
        </LinearLayout>

        ...

    </RelativeLayout>
</ScrollView>

...

将工具栏放在滚动视图之外,滚动不会影响工具栏

您需要在工具栏和滚动视图周围添加额外的线性布局,如下所示

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/create_advert_container_toolbar"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical">

    <android.support.v7.widget.Toolbar
        android:id="@+id/createAdvertToolbar"
        app:popupTheme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:background="?attr/colorPrimary"
        android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" />

    <ScrollView
        android:id="@+id/svCreateAdvert"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fillViewport="true">

        <RelativeLayout 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:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="@color/grey"
            android:orientation="vertical"
            tools:context=".CreateAdvert">

        </RelativeLayout>
    </ScrollView>
</LinearLayout>

将工具栏放在滚动视图之外,滚动不会影响工具栏

您需要在工具栏和滚动视图周围添加额外的线性布局,如下所示

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/create_advert_container_toolbar"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical">

    <android.support.v7.widget.Toolbar
        android:id="@+id/createAdvertToolbar"
        app:popupTheme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:background="?attr/colorPrimary"
        android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" />

    <ScrollView
        android:id="@+id/svCreateAdvert"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fillViewport="true">

        <RelativeLayout 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:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="@color/grey"
            android:orientation="vertical"
            tools:context=".CreateAdvert">

        </RelativeLayout>
    </ScrollView>
</LinearLayout>


将工具栏放在scrollview之外?是否将工具栏放在scrollview之外?