尽管实现了所有必需的参数,但CoordinatorLayout不会在滚动时隐藏工具栏 [英] CoordinatorLayout does not hide Toolbar on scrolling despite implementing all required parameters

查看:94
本文介绍了尽管实现了所有必需的参数,但CoordinatorLayout不会在滚动时隐藏工具栏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的设置,我正在运行 DrawerLayout ,其中是一个 CoordinatorLayout,其中包含一个AppBarLayout和一个嵌套滚动视图.我正在尝试使nestedscrollview正常滚动,并在向下滚动时隐藏工具栏,在向上滚动时重新显示工具栏.随附的是我的XML代码.感谢您提供帮助..已阅读所有相关问题并成功实施了答案.

Here is my setup, i am running a DrawerLayout, within it is a CoordinatorLayout containing an AppBarLayout and a nestedscrollview. I am trying to have the nestedscrollview scroll normally and the Toolbar to get hidden on scrolling down and reppear on scrolling up. Attached within is my XML code. Would appreciate any help.. have read all related questions and implemented their answers without any success.

<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/drawer_layout_admin"
android:layout_width="match_parent"
android:layout_height="match_parent">

<android.support.design.widget.CoordinatorLayout
    android:id="@+id/admincoordinator"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <android.support.design.widget.AppBarLayout
        android:id="@+id/appBarLayout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <include
            android:id="@+id/app_bar"
            layout="@layout/app_bar"
            app:layout_scrollFlags="scroll|enterAlways" />

        <android.support.design.widget.TabLayout
            android:id="@+id/tabLayout"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />
    </android.support.design.widget.AppBarLayout>

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

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

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

推荐答案

我有一个星期遇到同样的问题,并尝试了所有解决方法. 但是我设法解决了这个问题.

I have had the same issue for a week and tried almost everything to solve it. However I managed to solve the issue.

您有类似...的地方

<include
    android:id="@+id/app_bar"
    layout="@layout/app_bar"
    app:layout_scrollFlags="scroll|enterAlways" />

...将此内容替换为您的app_bar.xml布局中的任何内容.例如:

...replace this with whatever is in your app_bar.xml layout. For example:

<android.support.v7.widget.Toolbar
    android:id="@+id/main_toolbar"
    style="@style/AppTheme.Toolbar"
    android:layout_height="wrap_content"
    android:layout_width="match_parent"
    app:layout_scrollFlags="scroll|enterAlways"/>

似乎出于某些原因,使用<include>标签滚动CoordinatorLayout无效.

It seems that for some reason, scrolling with CoordinatorLayout does not work when using the <include> tag.

这篇关于尽管实现了所有必需的参数,但CoordinatorLayout不会在滚动时隐藏工具栏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆