Android 滚动recyclerview时无法隐藏工具栏,因为它正在做此论坛中发布的所有事情
正如标题所示,当我滚动recyclerview时,我无法隐藏工具栏。 我有两个标签,里面有一个fragmet和一个recyclerview 这里是我的XML代码。每个回收站视图都有一行Android 滚动recyclerview时无法隐藏工具栏,因为它正在做此论坛中发布的所有事情,android,scroll,android-recyclerview,toolbar,Android,Scroll,Android Recyclerview,Toolbar,正如标题所示,当我滚动recyclerview时,我无法隐藏工具栏。 我有两个标签,里面有一个fragmet和一个recyclerview 这里是我的XML代码。每个回收站视图都有一行app:layout\u behavior=“@string/appbar\u scrolling\u view\u behavior”,收费站有一个标志app:layout\u scrollFlags=“scroll | enterally | snap” 片段1 <android.support.v7.w
app:layout\u behavior=“@string/appbar\u scrolling\u view\u behavior”
,收费站有一个标志app:layout\u scrollFlags=“scroll | enterally | 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_主屏幕
<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
中,谢谢您,但现在我有两个新问题,第一个问题:工具栏滚动和RecyclerView滚动不同步。第二个:recyclerview的第一项位于工具栏和选项卡后面。你能帮忙吗?@AradityAbrahmbhatt我只需要在viewpager中添加一行“app:layout_behavior=“@string/appbar_scrolling_view_behavior”,神奇的是,所有的bug都被修复了,哈哈