2014-12-11 2 views
0

ImageView에서 스케일 애니메이션을 실용적으로 설정할 때 약간의 문제가 있습니다. 기본적으로 나는 이미지 뷰를 중심 H/V로 설정했지만 애니메이션을 적용하면 다음과 같이 설정됩니다. (... Iv는 피벗 x/y에 대해 50 %로 설정되었지만 작동하지는 않을 것입니다. ?Android ScaleAnimation이 화면 중앙에 있지 않음

AnimationSet set = new AnimationSet(true); 
    Animation animation = new ScaleAnimation(1, 1.2f, 1, 1.2f, Animation.ABSOLUTE, 50, Animation.ABSOLUTE, 50); 
    animation.setDuration(500); 
    animation.setRepeatCount(-1); 
    animation.setRepeatMode(Animation.RESTART); 
    set.addAnimation(animation); 

    animation = new ScaleAnimation(1.2f, 1.4f, 1.2f, 1.4f, Animation.ABSOLUTE, 50, Animation.ABSOLUTE, 50); 
    animation.setDuration(500); 
    animation.setRepeatCount(-1); 
    animation.setRepeatMode(Animation.RESTART); 
    set.addAnimation(animation); 

    animation = new ScaleAnimation(1.4f, 1.0f, 1.4f, 1.0f, Animation.ABSOLUTE, 50, Animation.ABSOLUTE, 50); 
    animation.setDuration(500); 
    animation.setRepeatCount(-1); 
    animation.setRepeatMode(Animation.RESTART); 
    set.addAnimation(animation); 

    image_view.startAnimation(set); 
어쩌면

enter image description here

답변

3

Animation.RELATIVE_TO_SELF 또는 Animation.RELATIVE_TO_PARENT 아래 좋은 것 ... 스크린 샷은 작업 예를 수행합니다

new ScaleAnimation(1, 1.2f, 1, 1.2f, 
      Animation.RELATIVE_TO_SELF, 0.5f, 
      Animation.RELATIVE_TO_SELF, 0.5f)); 

왼쪽부터 계산, 모두 0.5f퍼센트 (50)과 같은 치료를/상단

+1

Waheeey ... 건배 남자 :) ... 강타 – user3024760