4

I have use Scale Animation for zooming an image in my app. It's working fine zoom image level proper which we want but my issue is when zooming the image not zoom smoother. image size is 1.4 mb.

ScaleAnimation scaleAnimation = new ScaleAnimation(1f, 2.5f,
                        1f, 2.5f, Animation.RELATIVE_TO_PARENT,
                        1.05f, Animation.RELATIVE_TO_PARENT, 1.05f);
  scaleAnimation.setFillAfter(true);
  scaleAnimation.setDuration(400);
  img.startAnimation(scaleAnimation);
tech_android
  • 719
  • 1
  • 7
  • 18

3 Answers3

3

If your min sdk version is greater than 13 then you can try

img.animate().scaleX(2.5f).scaleY(2.5f).setDuration(400).start();
Akshay Bhat 'AB'
  • 2,690
  • 3
  • 20
  • 32
1

Android animations with Zoom animation smoothly Here.

You can custom them for making more smooth.

Sohail Zahid
  • 8,099
  • 2
  • 25
  • 41
0

Create scale_up.xml:

<set xmlns:android="http://schemas.android.com/apk/res/android">
    <scale android:fromXScale="1"
           android:fromYScale="1"
           android:toXScale="1.2"
           android:toYScale="1.2"
           android:pivotX="50%"
           android:pivotY="50%"
           android:duration="400"/>
</set>

and Use this way..

Animation animation = AnimationUtils.loadAnimation(this, R.anim.scale_up);
((ImageView) findViewById(R.id.circle_image)).startAnimation(animation );

It will give you smooth Animation.

Note : make sure that to get smooth animation you have to set android:pivotX and android:pivoty to half of screen.

Harshad Pansuriya
  • 20,189
  • 8
  • 67
  • 95