Animate zoom in via center of an image in Android with xml

I am trying to do some simple image zooming and panning with android and I have two simple questions. First, when I call the animation using scale, it zooms using the upper left hand corner of the image as the origin but I would like it to zoom from the center of the image. Second question is once the animation is done it resets the image to the original state and I would like it to stay at the final state.

Here is the xml I have for the scale:

  • How to show toast in AsyncTask in doInBackground
  • Proper way to find if a paired Android Bluetooth device is in range?
  • How to add “Go Back” function in WebView inside Fragment?
  • GCMRegistrar.getRegistrationId(this) always returns empty string, even after successful call to register
  • Open ServiceMode menu programatically in Android
  • Gradle fails building with “Missing project_info object”
  • <scale android:fromXScale="1.0"

    and in my code:

    a = AnimationUtils.loadAnimation(this, R.anim.set);
    ImageView iv = (ImageView) findViewById(;

    Any help would be appreciated! 🙂

    Related posts:

    Unnecessary padding in CardView?
    How large are the steps on onAdjustVolume of the VolumeProvider?
    How to make my ImageView zoomable?
    Programmatically make a color more transparent
    Android, how to choose save file location?
    how to navigate to error lines in Android Studio by shortcut?
  • In-App screen recording on android to capture 15 frames per second
  • Inflate layout on ListItem based on ListItem specific variable
  • How to Call Native Iphone/Android function from Javascript?
  • android asynctask sending callbacks to ui
  • Reverse the direction of a LinearLayout
  • Android: How to use “adb shell wm” to simulate other devices
  • One Solution collect form web for “Animate zoom in via center of an image in Android with xml”

    For scaling a image from center you have to set the pivotX and pivotY

    try this code for scaling from center and retaining the state after scaling,

    <scale  xmlns:android=""


    Android Babe is a Google Android Fan, All about Android Phones, Android Wear, Android Dev and Android Games Apps and so on.