2016-12-13 7 views
0

여기에 X 방향 (왼쪽에서 오른쪽)으로 이미지 뷰를 번역하는 코드가 있습니다.번역 displace imageview

final Animation animTrans = new TranslateAnimation(0f, 1f, 0f, 0f); 
     animTrans.setRepeatCount(0); 
     animTrans.setDuration(200); 
     animTrans.setFillAfter(true); 
     circleImage.startAnimation(animTrans); 

번역을 시작하면 이미지가 y 축에서 벗어납니다. 여기 happpens의 그림이 있습니다. enter image description here

하지만 xml을 사용하면 모든 것이 올바르게 작동합니다. 내 코드의 문제점은 무엇입니까?

하여 XML :

<translate 
     android:fromXDelta="0%p" 
     android:toXDelta="80%p" 
     android:duration="200" 
     android:fillAfter="true" 
     /> 

답변

0

나는 이유를 알 수는 없지만,

circleImage.animate(). 
       translationXBy(width). 
       setDuration(200). 
       start(); 

내 문제를 해결했다. 아마도 final Animation animTrans = new TranslateAnimation(0f, 1f, 0f, 0f);의 문제라고 생각합니다. 그 xdelta, ydelta 값이 이유 일 수 있습니다.