简体   繁体   English

滚动RecyclerView时无法隐藏工具栏,可能是原因?

[英]Unable to hide Toolbar while scrolling RecyclerView, possible cause?

I am trying to hide the ToolBar as the RecyclerView gets scrolled, however, ToolBar doesn't hide or move at all. 我正在尝试在滚动RecyclerView时隐藏ToolBar ,但是, ToolBar根本不会隐藏或移动。 This is how I implemented it: 这是我的实现方式:

<android.support.design.widget.CoordinatorLayout
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="match_parent"
android:fitsSystemWindows="true">

<android.support.design.widget.AppBarLayout
    android:layout_height="wrap_content"
    android:background="?colorPrimary"
    android:elevation="@dimen/margin_8"
    android:layout_width="match_parent"
    android:id="@+id/appbar">

    <android.support.v7.widget.Toolbar
        android:id="@+id/toolbar"
        app:layout_scrollFlags="scroll|enterAlways"
        android:layout_marginLeft="@dimen/list_toolbar_side_margin"
        android:layout_marginRight="@dimen/list_toolbar_side_margin"
        android:layout_width="match_parent"
        android:layout_height="?actionBarSize"
        android:background="?attr/colorPrimary">

        <TextView
            android:id="@+id/titleText"
            android:text="@string/app_name"
            android:gravity="start|center"
            android:textSize="19sp"
            android:layout_width="match_parent"
            android:layout_height="match_parent" />
    </android.support.v7.widget.Toolbar>

</android.support.design.widget.AppBarLayout>
<FrameLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:layout_behavior="@string/appbar_scrolling_view_behavior"
    >


        <android.support.v7.widget.RecyclerView
            android:id="@+id/homeTeamRView"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:clipToPadding="false"
            android:scrollbarStyle="outsideOverlay"
            android:paddingLeft="@dimen/list_side_margin"
            android:paddingRight="@dimen/list_side_margin"
            android:paddingBottom="@dimen/margin_16" />

</FrameLayout>

How to fix ? 怎么修 ?

要解决此问题,请添加Toolbar小部件( android.support.v7.widget.Toolbar ):

 app:layout_scrollFlags="scroll|enterAlways"

<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"
        app:layout_scrollFlags="scroll|enterAlways"
       />

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

<include layout="@layout/content_eez_dine_home" />

As like above 就像上面

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 工具栏不会自动隐藏,在recyclerview中滚动时需要手动按下才能隐藏 - toolbar is not hiding automatically need to push manually to hide while scrolling in recyclerview 如何在recyclelerView向下滚动时折叠后隐藏工具栏 - How to hide toolbar after collapsing while recyclerView scrolling down 滚动时隐藏工具栏 - hide Toolbar while scrolling CollapsingToolbarLayout 并在滚动时隐藏工具栏 - CollapsingToolbarLayout and hide toolbar while scrolling 通过在Fragment中滚动recyclerview来隐藏活动中的工具栏? - Hide toolbar in activity by scrolling a recyclerview inside the Fragment? 工具栏不会隐藏在DrawerLayout中的Scrolling recyclerview上 - Toolbar doesn't hide on Scrolling recyclerview in DrawerLayout 滚动recyclerview时android折叠的工具栏反弹 - android collapsing toolbar bounce while scrolling recyclerview 滚动片段工具栏应隐藏在android中 - While Scrolling Fragment toolbar should hide in android 如何在相对布局中有效滚动时隐藏工具栏? - How to hide toolbar while scrolling efficientliy in relativeLayout? 滚动recyclerview时如何在状态栏下完全隐藏工具栏 - How to hide toolbar fully under status bar when scrolling recyclerview
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM