无法在一台设备上的某些片段上滚动 RecyclerView

Unable to scroll RecyclerView on some fragments on one device

我有一些奇怪的问题,现在才注意到。我有 ViewPager 和 3 个片段,使用与 RecyclerView 相同的布局,它适用于我测试的 4 台设备(Nexus 7、HTC 816、HTC 610 和 Xperia SP),但它不适用于 Nexus S .

滚动仅在最后一个片段上正常工作,但在前两个片段上您需要从列表的顶部或底部开始滚动。

这是使用的布局:

<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.RecyclerView
    android:id="@+id/recycler_dictionary"
    android:layout_height="wrap_content"
    android:layout_width="match_parent"
    android:scrollbars="vertical"
    android:clickable="true"
    android:background="@color/myLightPrimaryColor"
    xmlns:android="http://schemas.android.com/apk/res/android" />

唯一的区别在于代码:

(这个不行)

@Override
    protected void updateDisplay() {
        // get new word count
        newWords    = SharedPrefsHelper.getDictionaryCountDifference(getActivity());
        adapter     = new DictionaryAdapter(listDictionary, getActivity(), newWords);
        recyclerView.setAdapter(adapter);
    }

(这个有)

@Override
    protected void updateDisplay() {
        // sort words by best voted (upvote - downvote)
        Comparator<Dictionary> comparator = new Comparator<Dictionary>() {
            @Override
            public int compare(Dictionary lhs, Dictionary rhs) {
                int leftLike, leftDislike, rightLike, rightDislike;

                if (lhs.getLikes() == null)
                    leftLike = 0;
                else leftLike = Integer.parseInt(lhs.getLikes());

                if (lhs.getDislikes() == null)
                    leftDislike = 0;
                else leftDislike = Integer.parseInt(lhs.getDislikes());

                if (rhs.getLikes() == null)
                    rightLike = 0;
                else rightLike = Integer.parseInt(rhs.getLikes());

                if (rhs.getDislikes() == null)
                    rightDislike = 0;
                else rightDislike = Integer.parseInt(rhs.getDislikes());

                return (rightLike - rightDislike) - (leftLike - leftDislike);
            }
        };

        Collections.sort(listDictionary, comparator);
        adapter = new DictionaryAdapter(listDictionary, getActivity());
        recyclerView.setAdapter(adapter);

我不明白为什么那部分代码会有什么不同。

看来我没有看对地方来解决这个问题。ViewPager 动画导致了问题,具体来说就是这个问题:

pager.setPageTransformer(true, new DepthPageTransformer());

那是来自 https://github.com/ToxicBakery/ViewPagerTransforms 的动画,但其他动画有效(没有测试所有动画)。它在任何 4.1 Android 设备上都不起作用,又尝试了一个和模拟器。