【问题标题】:Androids CoordinatorLayout scroll behavior to deeper child viewsAndroid CoordinatorLayout 滚动行为到更深的子视图
【发布时间】:2017-06-04 04:01:23
【问题描述】:

简单的问题:

如何将滚动行为附加到不是 CoordinatorLayout 的直接子级的 RecyclerView?

<CoordinatorLayout id="root">
    <AppBarLayout>
        <Toolbar/>
    </AppBarLayout>
    <FrameLayout id ="fragment_container">
        <RecyclerView id="list" behavior="..."/>
    </FrameLayout>
</CoordinatorLayout>

我为什么要这个?

我有一个活动,它包含工具栏,并有一个用于内容的主槽,如“Foo”列表。该列表被封装在一个 Fragment 中,该 Fragment 包含一个带有 RecyclerView、空 State TextView 和一个 ProgressView 的 FrameLayout。问题是我的 RecyclerView 中的第一行位于工具栏后面。

【问题讨论】:

标签: android android-recyclerview android-coordinatorlayout


【解决方案1】:

尝试用 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 的父视图

对我有用

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-12-04
    • 2017-01-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-08-24
    • 2015-12-15
    • 1970-01-01
    相关资源
    最近更新 更多