动画拆除一个ListView项目动画、项目、ListView

2023-09-05 05:38:28 作者:和好不如初

我试图用这个动画的去除ListView项的:

I'm attempting to animate the removal of a ListView item using this:

    mListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> adapterView, final View view, final int i, long l) {
            view.animate().setDuration(500).x(-view.getWidth()).alpha(0f);
            adapter.remove(tasks.get(i));
            adapter.notifyDataSetChanged();
        }
    });

这是行不通的。我基本上遵循了4回答的意见,从这个帖子顶:

It does not work. I basically followed the advice of the 4th answer from the top of this post:

How为动画添加或删除Android的ListView的行

不过,有一些有趣的绘画的东西怎么回事,或者回收或东西,因为虽然动画时,下面的一个滑出屏幕的项目也被删除出于某种原因。这个问题提问者最终标记为正确的答案是不幸对整个Android的源的RTFM。我经过那里看着,我找不到通知下拉豆形软糖中,我试着效仿。

However, there's some funny drawing stuff going on, or recycling, or something because while the animation occurs, the item below the one that slides off screen also gets deleted for some reason. The answer that the question asker eventually marked as correct is unfortunately an RTFM towards the whole of Android's source. I've looked through there, and I can't find the notifications pull-down in JellyBean which I'm trying to emulate.

TIA。 约翰·

推荐答案

我刚刚发现了一个漂亮的解决办法:https://github.com/paraches/ListViewCellDeleteAnimation

I just found a beautiful solution: https://github.com/paraches/ListViewCellDeleteAnimation

下面的视频: http://www.youtube.com/watch?v=bOl5MIti7n0

非常感谢'paraches')

Many thanks to 'paraches' ;)