【发布时间】:2016-05-25 12:06:38
【问题描述】:
我正在尝试在一个带有 appbar 布局的 CoordinatorLayout 中使用两个 RecyclerView。 但问题是 第二个 recyclerview 与第一个 recyclerview 重叠,第一个 recyclerview 应该低于第一个 recyclerview。我正在为此搜索,但没有适当的解决方案。 CoordinatorLayout 是一个超级强大的 FrameLayout。
我的代码 sn-p 如下:
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:fab="http://schemas.android.com/apk/res-auto"
android:id="@+id/layout_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<android.support.design.widget.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="366dp"
android:fitsSystemWindows="true"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/collapsing_toolbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/selfie_collasping_toolbar_background"
android:fitsSystemWindows="true"
app:contentScrim="@color/colorPrimary_selfie"
app:expandedTitleMarginBottom="255dp"
app:expandedTitleMarginStart="70dp"
app:layout_scrollFlags="scroll|exitUntilCollapsed"
app:title="Check ins">
<RelativeLayout
android:id="@+id/collapsing_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="70dp"
android:fitsSystemWindows="true"
app:layout_collapseMode="parallax"
app:layout_scrollFlags="scroll|enterAlways|enterAlwaysCollapsed">
<ImageView
android:id="@+id/offer_gift"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginLeft="15dp"
android:layout_marginTop="5dp"
android:src="@mipmap/image" />
</RelativeLayout>
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_collapseMode="pin"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<RelativeLayout
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/RecyclerView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="3dp"
android:layout_marginLeft="3dp"
android:layout_marginRight="3dp"
android:layout_marginTop="15dp" />
<android.support.v7.widget.RecyclerView
android:id="@+id/RecyclerView2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/RecyclerView1"
android:layout_marginBottom="3dp"
android:layout_marginLeft="3dp"
android:layout_marginRight="3dp"
android:layout_marginTop="15dp" />
</RelativeLayout>
<com.getbase.floatingactionbutton.FloatingActionsMenu
android:id="@+id/fab"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="bottom|right">
---
</com.getbase.floatingactionbutton.FloatingActionsMenu>
</android.support.design.widget.CoordinatorLayout>
如果回收器视图是 CoordinatorLayout 的主要子视图,那么我将获得正确的回收器视图行为。但是如果使用两个回收器视图作为 CoordinatorLayout 的子级,那么两个回收器视图会发生碰撞。如果我在 recyclerview2 使用 layout_below,则数据不会显示 recyclerview2,即 CoordinatorLayout 滚动条滚动到仅 recyclerview1 数据...
【问题讨论】:
-
你能详细说明你想要实现什么吗?
标签: android android-recyclerview android-coordinatorlayout