recycleler view 23.2.0 fling scrolling

时间:2016-02-26 13:20:24

标签: android android-recyclerview

在将循环器视图更新到23.2.0后,我注意到滚动滚动不再像以前那样工作了。除了适应回收站视图的新自动调整大小之外,我还没有改变任何其他代码。还有其他人遇到过类似的问题吗?

这是我的代码:

XML:

 <android.support.v4.widget.NestedScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layout_behavior="@string/appbar_scrolling_view_behavior">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical">

            <android.support.v7.widget.RecyclerView
                android:id="@+id/my_recycler_view"
                android:layout_width="match_parent"
                android:layout_height="wrap_content" />
        </LinearLayout>

    </android.support.v4.widget.NestedScrollView>

Java:

 mRecyclerView = (RecyclerView) findViewById(R.id.my_recycler_view);
 mRecyclerView.setHasFixedSize(true);
 mRecyclerView.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.VERTICAL,false));

2 个答案:

答案 0 :(得分:2)

这对我有用:

mRecyclerView.setLayoutManager(new LinearLayoutManager(getContext(), LinearLayoutManager.VERTICAL, false) {

        @Override
        public boolean canScrollHorizontally() {
            return false;
        }

        @Override
        public boolean canScrollVertically() {
            return false;
        }
    });

答案 1 :(得分:0)

我遇到了类似的问题。我在活动的布局中替换了NestedScrollView:

<android.support.v4.widget.NestedScrollView
    android:id="@+id/fragment_container"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    app:layout_behavior="@string/appbar_scrolling_view_behavior" />

到FrameLayout:

<FrameLayout
    android:id="@+id/fragment_container"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:layout_behavior="@string/appbar_scrolling_view_behavior" />

PS。此代码适用于支持库版本23.2.1。

相关问题