【问题标题】:Coordinator Layout with 2 Recycler Views具有 2 个回收站视图的协调器布局
【发布时间】:2019-01-10 16:36:22
【问题描述】:

我想用这个布局构建一个 android 片段:

  1. 屏幕的上半部分是一个水平滚动的 RecyclerView。
  2. 屏幕的下半部分是一个可垂直滚动的 RecyclerView。

当底部 RecyclerView 向底部滚动时,我希望顶部的 RecyclerView 折叠和隐藏(并在底部视图滚动到顶部时打开)。

协调器布局似乎是答案,但我遇到的每个示例都使用 AppBarLayout 作为顶部。包含该片段的活动已经显示了一个应用栏;我不想修改它。

如何在 CoordinatorLayout 中实现这两个 RecyclerView 设置而不解决应用栏?

【问题讨论】:

    标签: android android-recyclerview android-coordinatorlayout


    【解决方案1】:

    您可以使用NestedScrollView、垂直方向的LinearLayout 作为NestedScrollView 的子级,并将RecyclerViews 添加为LinearLayout 的子级

    样本

    <android.support.v4.widget.NestedScrollView
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical">
            <android.support.v7.widget.RecyclerView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"/>
    
            <android.support.v7.widget.RecyclerView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"/>
        </LinearLayout>
    </android.support.v4.widget.NestedScrollView>
    

    【讨论】:

      猜你喜欢
      • 2019-10-19
      • 1970-01-01
      • 1970-01-01
      • 2019-12-24
      • 2020-12-12
      • 1970-01-01
      • 1970-01-01
      • 2022-06-10
      • 2022-01-18
      相关资源
      最近更新 更多