0
我想知道如何强制RecyclerView做适当/漂亮的动画,同时删除具有固定位置和特定布局的项目之前的项目。RecyclerView动画onRemove与固定项目
我试图建立在此tutorial,这工作正常,直到我的具体要求。
只需简单的修改教程代码:
@Override
public int getItemViewType(int position) {
if(position == 3){
return IREGULAR;
}
return REGULAR;
}
@Override
public ColorViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view;
if(viewType == REGULAR) {
view = LayoutInflater.from(parent.getContext()).inflate(R.layout.list_item, parent, false);
}else{
view = LayoutInflater.from(parent.getContext()).inflate(R.layout.list_item_iregular, parent, false);
}
// rest of tutorial code down here
}
@Override
public void onBindViewHolder(ColorViewHolder holder, int position) {
int color;
if(getItemViewType(position) == REGULAR) {
color = colors.get(position);
}else{
color = 0xFF000000;
}
// rest of tutorial code down here
}
那么第三个项目将是有点偏高,且总是黑色。
正如你可以在图片上面看,直到下第三位置(iregular一个)项目被删除动画作品很好,但同时它上面再大的黑色空间,出现在那里的项目都重新绑定。 我该如何完成更好的动画体验?
这可能是正确的答案,而它确实效果很好在上述演示。但在我的真实项目中,它无法正常工作。也许这是由于更复杂的布局,花费在onCreate和onBind方法上。 在演示中它几乎是0ms,在我的真实项目中它是在5-33ms之间。 – ThinkDeep