【发布时间】:2015-04-11 16:48:20
【问题描述】:
我正在尝试实现从列表视图中删除项目的动画。然后项目的动画从左到右(删除时离开屏幕)我在其下方的视图上运行动画以向上移动并卡入到位,但问题是 listview 检测到删除时列表闪烁。 我运行动画的代码是:
Animation an = AnimationUtils.loadAnimation(MainActivity.this, R.anim.offscreen);
itemc.setHasTransientState(true);
itemc.startAnimation(an);
final Handler handler = new Handler();
handler.postDelayed(new Runnable() {
@Override
public void run() {
l.remove(positionc);
adapter.remove(positionc);
// adapter.notifyDataSetChanged();
}
}, 1050);
//animate below views to position
ArrayList<View> vl=new ArrayList<View>();
//for loop runs and saves all the views below the deleted view
for(int i=position+1;i<=listView.getLastVisiblePosition();i++)
{
vl.add(listView.getChildAt(i));
}
//one by one animation is performed on all the views
ListIterator itr=vl.listIterator();
while(itr.hasNext())
{
View v =(View)itr.next();
v.setHasTransientState(true);
v.animate().setDuration(500).translationYBy(- itemc.getHeight());//iteam is the view deleted
}
【问题讨论】:
标签: android listview android-listview android-animation