2017-10-17 139 views
0

如何使从当前位置到在列表视图Android其它用户选择的位置移动动画,如何使从当前位置到列表视图中的其他选定位置移动动画?

在我的列表视图,我想在其中用户选择的位置的动画(currentPosition = 5)。 以后如果用户将改变选择的位置(currentPosition = 8,一位置= 5)

我需要动画等:从一位置(5)〜currentPosition(8)的ImageView的拖动(从第五位置到第八位置移动或者(如果用户改变位置的ImageView从第八位置移动到第10位) 请问有什么可以做呢?

我没有发现正是我要找的,从这个
但除此之外,我发现从谷歌的链接(Zooming in a view),这将从currentPosition中缩放imageView,但它不是我正在寻找的。

请帮忙。

+0

这将是**简单得多**如果你使用'RecyclerView'和'(如,它在默认情况下做到这一点) DiffCallback'。如果你正在尝试做一个非常简单的列表,不要使用ListView。 – CommonsWare

+0

@CommonsWare你能解释一些更多。究竟如何? 是的,我正在使用recyclerView。 – Dhiren

+0

“是的,我正在使用recyclerView” - 不是根据你的问题。我很抱歉,班级是'DiffUtil',而不是'DiffCallback'。请参阅[JavaDocs](https://developer.android.com/reference/android/support/v7/util/DiffUtil.html),[此Caster.IO介绍](https://caster.io/lessons/recyclerview -animate-complex-content-changes-with-diffutil /),[this Medium post](https://medium.com/@gabornovak/use-diffutil-for-out-of-the-box-animations-d932a28d6229)等 – CommonsWare

回答

0

使用RecyclerView您可以直接从一个位置移动到另一个使用

/** 
     * Notify any registered observers that the item reflected at <code>fromPosition</code> 
     * has been moved to <code>toPosition</code>. 
     * 
     * <p>This is a structural change event. Representations of other existing items in the 
     * data set are still considered up to date and will not be rebound, though their 
     * positions may be altered.</p> 
     * 
     * @param fromPosition Previous position of the item. 
     * @param toPosition New position of the item. 
     */ 
     public final void notifyItemMoved(int fromPosition, int toPosition) { 
      mObservable.notifyItemMoved(fromPosition, toPosition); 
     } 
+0

我不想在这里移动一个项目,我只是想动画imageView,从lastPosition到currentPosition。 – Dhiren

相关问题