滚动 recyclerview 执行此论坛中发布的所有内容时无法隐藏工具栏
Cannot hide toolbar when scrolling recyclerview doing all things posted in this forum
如标题所示,我无法在滚动回收站视图时隐藏工具栏。
我有两个选项卡,里面都有一个 fragmet,里面都有一个 recyclerview
这是我的 XML 代码。每个 recyclerview 都有行 app:layout_behavior="@string/appbar_scrolling_view_behavior"
并且收费栏有标志 app:layout_scrollFlags="scroll|enterAlways|snap"
片段 1
<android.support.v7.widget.RecyclerView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="match_parent"
android:layout_width="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:padding="4dp"
android:scrollbars="vertical"
android:id="@+id/ftvl_RecyclerView"
android:layoutAnimation="@anim/layout_animation_fall_down"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
片段 2
<android.support.v7.widget.RecyclerView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="match_parent"
android:layout_width="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:padding="4dp"
android:scrollbars="vertical"
android:id="@+id/ftasl_RecyclerView"
android:layoutAnimation="@anim/layout_animation_fall_down"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
AppBar_MainScreen
<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"
tools:context=".Screens.MainScreen.MainScreen.MainScreen">
<LinearLayout
android:id="@+id/linearLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
<android.support.v7.widget.Toolbar
android:id="@+id/cms_toolbar"
android:layout_width="match_parent"
android:layout_height="?android:attr/actionBarSize"
android:background="@color/colorPrimary"
app:popupTheme="@style/Theme.AppCompat.Light"
app:layout_scrollFlags="scroll|enterAlways|snap"
app:title="Disco App">
</android.support.v7.widget.Toolbar>
<android.support.design.widget.TabLayout
android:id="@+id/cms_tabLayout"
android:layout_width="match_parent"
android:layout_height="35dp"
android:background="@color/colorPrimary"
android:minHeight="30dp"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:tabMode="fixed">
</android.support.design.widget.TabLayout>
</android.support.design.widget.AppBarLayout>
<include layout="@layout/content_main_screen" />
</LinearLayout>
<android.support.design.widget.FloatingActionButton
android:id="@+id/cms_fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_margin="@dimen/fab_margin"
app:layout_anchor="@+id/linearLayout"
app:layout_anchorGravity="right|bottom"
app:srcCompat="@android:drawable/ic_dialog_email" />
谁能帮帮我?谢谢
啊!如果您查看 AppBarLayout
,它被包裹在 LinearLayout
中。但是 AppBarLayout
应该永远是 CoordinatorLayout
的直系子代。如果仍然不起作用,请尝试将 RecyclerView
包裹在 NestedScrollView
.
内
如标题所示,我无法在滚动回收站视图时隐藏工具栏。 我有两个选项卡,里面都有一个 fragmet,里面都有一个 recyclerview
这是我的 XML 代码。每个 recyclerview 都有行 app:layout_behavior="@string/appbar_scrolling_view_behavior"
并且收费栏有标志 app:layout_scrollFlags="scroll|enterAlways|snap"
片段 1
<android.support.v7.widget.RecyclerView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="match_parent"
android:layout_width="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:padding="4dp"
android:scrollbars="vertical"
android:id="@+id/ftvl_RecyclerView"
android:layoutAnimation="@anim/layout_animation_fall_down"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
片段 2
<android.support.v7.widget.RecyclerView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="match_parent"
android:layout_width="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:padding="4dp"
android:scrollbars="vertical"
android:id="@+id/ftasl_RecyclerView"
android:layoutAnimation="@anim/layout_animation_fall_down"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
AppBar_MainScreen
<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"
tools:context=".Screens.MainScreen.MainScreen.MainScreen">
<LinearLayout
android:id="@+id/linearLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
<android.support.v7.widget.Toolbar
android:id="@+id/cms_toolbar"
android:layout_width="match_parent"
android:layout_height="?android:attr/actionBarSize"
android:background="@color/colorPrimary"
app:popupTheme="@style/Theme.AppCompat.Light"
app:layout_scrollFlags="scroll|enterAlways|snap"
app:title="Disco App">
</android.support.v7.widget.Toolbar>
<android.support.design.widget.TabLayout
android:id="@+id/cms_tabLayout"
android:layout_width="match_parent"
android:layout_height="35dp"
android:background="@color/colorPrimary"
android:minHeight="30dp"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:tabMode="fixed">
</android.support.design.widget.TabLayout>
</android.support.design.widget.AppBarLayout>
<include layout="@layout/content_main_screen" />
</LinearLayout>
<android.support.design.widget.FloatingActionButton
android:id="@+id/cms_fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_margin="@dimen/fab_margin"
app:layout_anchor="@+id/linearLayout"
app:layout_anchorGravity="right|bottom"
app:srcCompat="@android:drawable/ic_dialog_email" />
谁能帮帮我?谢谢
啊!如果您查看 AppBarLayout
,它被包裹在 LinearLayout
中。但是 AppBarLayout
应该永远是 CoordinatorLayout
的直系子代。如果仍然不起作用,请尝试将 RecyclerView
包裹在 NestedScrollView
.