【发布时间】:2016-11-25 09:32:01
【问题描述】:
当RecyclerView 滚动时,我试图隐藏ToolBar,但是,ToolBar 根本没有隐藏或移动。这就是我实现它的方式:
<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>
如何解决?
【问题讨论】:
-
app:layout_scrollFlags应该在AppBarLayout中。你有足够的内容来滚动吗? -
是的,20 张图片,按回收站视图的线性顺序排列,我相信足以滚动
-
@Blackbelt 在
AppBarLayout中尝试过的效果不佳!
标签: android xml android-recyclerview android-coordinatorlayout