RecyclerView不断更改尺寸

时间:2016-06-28 21:58:28

标签: android android-recyclerview

我正在尝试建立一个有吸引力的回收视图,但尺寸不断变化,我不知道为什么 如果我向上/向下滚动它会改变 这是一个截图,然后向下滚动然后向上的例子:

First screenshot

Second screenshot after scrolling down/up

适配器:

pastebin.com/jYRXJSMe

pastebin.com/m0JMrpwr

    /* Code for the recycler */
    mRecycler = (RecyclerView)findViewById(R.id.activity_movies_recycler);
    mRecycler.addItemDecoration(new RecyclerInsetsDecoration(this));
    mRecycler.addOnScrollListener(recyclerScrollListener);
    mRecycler.setHasFixedSize(true);

    mRecycler.setDrawingCacheEnabled(true);
    mRecycler.setDrawingCacheQuality(View.DRAWING_CACHE_QUALITY_HIGH);

这是RecyclerInsetsDecoration的代码

public class RecyclerInsetsDecoration extends RecyclerView.ItemDecoration {

    private int mInsets;

    public RecyclerInsetsDecoration(Context context) {
        mInsets = context.getResources().getDimensionPixelSize(R.dimen.insets);
    }

    @Override
    public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {

        //We can supply forced insets for each item view here in the Rect
        super.getItemOffsets(outRect, view, parent, state);
        outRect.set(mInsets, mInsets, mInsets, mInsets);
    }
}

回收商布局: pastebin.com/37x9m9XN

0 个答案:

没有答案