2011-11-17 3 views
1

ScaleAnimation을 사용하여 ImageView의 크기를 조정했습니다. 그러나 애니메이션이 완료된 후 어떻게 내 ImageView의 치수 또는 비트 맵을 얻을 수 있습니까?ScaleAnimation 후에 View의 새로운 너비와 높이를 얻는 방법

ScaleAnimation animation = new ScaleAnimation(m_oldZoomRatio, m_currentZoomRatio, m_oldZoomRatio, m_currentZoomRatio); 

     animation.setFillAfter(true); 
     animation.setFillEnabled(true); 
     animation.setAnimationListener(new AnimationListener() { 

      public void onAnimationStart(Animation animation) { 
      } 

      public void onAnimationRepeat(Animation animation) { 
      } 

      public void onAnimationEnd(Animation animation) { 
      } 
     }); 
     m_child.startAnimation(animation); 

m_oldZoomRatio != m_currentZoomRatio : 덕분에 여기

내 코드입니다.

내보기가 실행되는 동안 레이아웃이 변경되는 것을 볼 수 있습니다. 그러나 너비와 높이를 가져올 때보기를 만들 때 원래 값을받습니다.

답변

1

애니메이션 끝에 당신이 당신의 응답을 폭과 높이

<animation-object>.setAnimationListener(new AnimationListener() 
    { 

     @Override 
     public void onAnimationEnd(Animation arg0) { 
      img.getWidth(); 
       img.getHeight(); 
        //OR 
       int h=img.getLayoutParams().height; 
       int w=img.getLayoutParams().width; 
       // For changing actual height and width 
      view.getLayoutParams().width = newWidth; 
       view.getLayoutParams().height = newHeight; 
view.requestLayout(); 

     } 

     @Override 
     public void onAnimationRepeat(Animation arg0) { 


     } 

     @Override 
     public void onAnimationStart(Animation arg0) { 


     } 

    }); 
+0

감사를 변경할 수 있습니다 애니메이션 리스너를 사용하려고합니다. 하지만 내 문제는 차원을 얻는 것입니다 (제안대로 설정하지 않는 것). – ndphu

+0

getHeight(), getWidth() 함수를 사용할 수있는 치수를 얻으려면 ... 그냥 대답 – Maneesh

+0

에서 편집 해 주셔서 감사합니다. 하지만 둘 다 ScaleAnimation 전에 뷰의 원래 치수를 반환합니다 (그러나 화면에서 ImageView의 크기가 이미 변경됨). – ndphu

관련 문제