public static void setSupportsChangeAnimations(ViewPager2 viewPager, boolean enable) {
for (int i =0; i < viewPager.getChildCount(); i++) {
View view = viewPager.getChildAt(i);
if (viewinstanceof RecyclerView) {
RecyclerView.ItemAnimatoranimator = ((RecyclerView) view).getItemAnimator();
if (animator !=null) {
((SimpleItemAnimator) animator).setSupportsChangeAnimations(enable);
}
break;
}
}
}
调用:
setSupportsChangeAnimations(viewpager,false);
网友评论