【发布时间】:2017-06-13 05:24:03
【问题描述】:
我不确定 RecyclerView 是否很难做到这一点,我认为有一种简单的方法可以做到这一点,但我遇到了一些困难。 我有一个活动的 RecyclerView,当我去活动时,我希望它滚动到一个项目。看起来还不错。但是,我的问题是,说一次只有 5 个项目适合屏幕,我们有 6 个项目,我们滚动到第 5 个或第 4 个项目,回收器视图确实滚动了一点点,但它看起来不像它滚动到元素,因为它受到 RecyclerView 边界的限制。
有没有办法做到这一点,如果我滚动到 RecyclerView 中的第 4 或第 5 项,它会将其定位在视图的顶部,最后一项下方的区域将只是正常视图,我可以正常滚动回来吗? 我希望我能正确地解释自己。我不确定这是否可以轻松完成,并且我在 XML 设置或代码设置中犯了错误。
<merge xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<include
android:id="@+id/timelineSwitcherView"
layout="@layout/view_timeline_view_switcher"/>
<ViewAnimator
android:id="@+id/viewAnimator"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/timelineSwitcherView">
<RelativeLayout
android:id="@+id/timeLineRelativeLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/lighterBlue">
<android.support.v4.widget.SwipeRefreshLayout
android:id="@+id/timeLineSwipeRefreshLayout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.RecyclerView
android:id="@+id/timeLineRecyclerView"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</android.support.v4.widget.SwipeRefreshLayout>
</RelativeLayout>
感谢任何帮助和指导。
【问题讨论】:
标签: java android xml list android-recyclerview