簡體   English   中英

具有2個Recycler視圖的協調器布局

[英]Coordinator Layout with 2 Recycler Views

我想用這種布局構建一個android片段:

  1. 屏幕的上半部分是一個RecyclerView,它可以水平滾動。
  2. 屏幕的下半部分是一個RecyclerView,它可以垂直滾動。

當底部的RecyclerView朝底部滾動時,我希望頂部的折疊起來並隱藏(並在底部視圖滾動到頂部時打開)。

協調器布局似乎是答案,但是我遇到的每個示例在頂部均使用AppBarLayout。 包含片段的活動已經顯示了一個應用欄。 我不想修改它。

我如何在CoordinatorLayout中實現這兩個RecyclerView設置,而無需解決應用程序欄?

您可以使用NestedScrollView (垂直方向的LinearLayout作為NestedScrollViewNestedScrollView ,並將兩個RecyclerView都添加為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>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM