RecyclerView 滑入动画不剪裁最后一项

RecyclerView slide-in animation without clipping last item

我有一个 RecyclerView,其中每个项目都是作为 fresco DraweeView 实现的缩略图。根据屏幕的大小,当 RecyclerView 首次加载时,最后一个缩略图有时是 "clipped"(这没问题)。

我实现了在初始加载时从右向左滑动 RecyclerView 的动画。我的动画使用 OvershootInterpolator,这就是问题所在:当发生超调时,最后一个 "clipped" 项目离开屏幕边缘,暴露缩略图比之前的缩略图窄(注意,RecyclerView 的正常滚动确实没有这个问题)。

这是我的slide_in_animation.xml

<set xmlns:android="http://schemas.android.com/apk/res/android">
    <translate
        android:duration="700"
        android:fromXDelta="100%"
        android:toXDelta="0%" />
</set>

这是加载动画的部分代码:

final Animation slideIn = AnimationUtils.loadAnimation(context,
    R.anim.slide_in_animation);
// overshoot slightly further than the default tension of 2.0f
slideIn.setInterpolator(new OvershootInterpolator(2.5f));
myRecyclerView.startAnimation(slideIn);

有没有什么方法可以让初始加载时屏幕上仅部分可见的最后一项在使用 OvershootInterpolator 设置动画时完全可见?

感谢您的帮助!

这是我想到的解决方案。希望其他人能从中受益:

1)使用RecyclerView容器的LayoutParams设置容器宽度为当前宽度的1.5倍
2) 做滑入动画
3) 使容器宽度与步骤 1 之前的宽度相同(将当前宽度减小 1.5 倍)。