Skip to content Skip to sidebar Skip to footer

How To Get The New Width And Height Of View After ScaleAnimation

I used a ScaleAnimation to resize my ImageView. But after the animation is complete, how can I get the dimension of my ImageView or the bitmap in that. Thanks Here is my code: Scal

Solution 1:

try to use animation listener where on animation end you can change the width and height

  <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) {


        }

     });

Post a Comment for "How To Get The New Width And Height Of View After ScaleAnimation"