2017-10-17 3 views
0

listview에서 현재 위치에서 다른 사용자가 선택한 위치로 애니메이션을 이동하는 방법,listview에서 현재 위치에서 다른 선택된 위치로 애니메이션을 이동하는 방법은 무엇입니까?

사용자가 위치 (currentPosition = 5)를 선택하는 애니메이션을 만들고 싶습니다. 나중에 사용자가 위치 (currentPosition = 8, lastPosition = 5)를 선택하도록 변경하면

나는 lastPosition (5)에서 currentPosition (8)까지 애니메이션이 필요합니다. imageView 드래그 (5 번째 위치에서 8 번째 위치로 이동 (사용자가 10 번째 위치로 8 번째 위치에서 이동 위치에 이미지 뷰를 변경하는 경우) 또는 내가 할 수있는 방법?

내가 정확히 찾을 수없는 나는이 그렇다
하지만, 찾고 무엇을, 나는 구글에서 링크를 발견 (Zooming in a view), currentPosition에서 imageView를 확대/축소합니다. 그러나 찾고있는 것이 아닙니다.

도와주세요.

+0

이 것 일 ** 훨씬 간단 ** 당신은''RecyclerView' 등을 사용한 경우 (, 그것은 기본적으로이 작업을 수행 같이) DiffCallback'. 꽤 단순한 목록 이외의 것을하려한다면 ListView를 사용하지 마십시오. – CommonsWare

+0

@CommonsWare에서 더 설명 해주실 수 있습니다. 얼마나 정확하게? 예, 저는 recyclerView를 사용하고 있습니다. – Dhiren

+0

"예, 나는 recyclerView를 사용하고 있습니다"- 귀하의 질문에 따르지 않습니다. 사과드립니다. 클래스는 DiffCallback이 아니라 DiffUtil입니다. [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 /), [이 중간 게시물] (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

여기에서 항목을 이동하고 싶지는 않습니다. 단순히 lastPosition에서 currentPosition까지 imageView를 애니메이션으로 만들고 싶습니다. – Dhiren

관련 문제