2014-03-05 3 views
2

나는 아래 이미지와 같은 응용 프로그램을 개발하고자하는랜덤 방향으로 안드로이드 Imageview를 움직이게하는 방법?

enter image description here

나는 이미지 뷰 1로 imageviews에게 2,3,4,5,6를 애니메이션을 적용 할 그 반대

하십시오 하나 이 작업을 수행하는 방법에 대한 도움을 받으십시오.

+0

모든 이미지 뷰의 애니메이션을 원하십니까? – Piyush

+0

@PiyushGupta 활동이 시작될 때 모든 이미지 뷰에 애니메이션을 적용하고 싶습니다. 중심 이미지 뷰를 클릭 할 때 – Krishna

+0

이 링크를보세요. https://github.com/siyamed/android-satellite-menu –

답변

2
int distance = 100; //the distance to move in pixels 
int duration = 500; //the duration of the animation in ms 

double direction = Math.random() * 2 * Math.PI; 

int translationX = Math.cos(direction) * distance; 
int translationY = Math.sin(direction) * distance; 

yourImageView.animate().translationX(translationX).translationY(translationY).setDuration(duration).start(); 
+0

이 답변은 제 요구 사항을 완료하는 데 도움이되었습니다. 감사 마크 – Krishna

+0

나를 위해 작동합니다. 여러 무작위 애니메이션에 좋습니다 –

관련 문제