Androids Coordinator布局滚动行为到更深的子视图
果壳中的问题: 如何将滚动行为附加到不是CoordinatorLayout直接子级的RecyclerViewAndroids Coordinator布局滚动行为到更深的子视图,android,android-recyclerview,android-coordinatorlayout,Android,Android Recyclerview,Android Coordinatorlayout,果壳中的问题: 如何将滚动行为附加到不是CoordinatorLayout直接子级的RecyclerView <CoordinatorLayout id="root"> <AppBarLayout> <Toolbar/> </AppBarLayout> <FrameLayout id ="fragment_container"> <RecyclerView id="list"
<CoordinatorLayout id="root">
<AppBarLayout>
<Toolbar/>
</AppBarLayout>
<FrameLayout id ="fragment_container">
<RecyclerView id="list" behavior="..."/>
</FrameLayout>
</CoordinatorLayout>
我为什么要这个
我有一个活动,它拥有工具栏,并有一个主槽,用于存放“Foo”列表之类的内容。该列表封装在一个片段中,该片段包含一个带有RecyclerView、empty State TextView和ProgressView的FrameLayout。问题是我的RecyclerView中的第一行在工具栏后面。尝试用NestedScrollView替换您的FrameLayout
<android.support.v4.widget.NestedScrollView
android:id="@+id/content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scrollbars="none"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
或者将其作为FrameLayout的父视图
这对我很有用尝试用NestedScrollView替换框架布局
<android.support.v4.widget.NestedScrollView
android:id="@+id/content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scrollbars="none"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
或者将其作为FrameLayout的父视图
它对我有用这是你的起点:这是你的起点: