set Rotation Center - Android Animation

Android examples for Animation:Rotate Animation

Description

set Rotation Center

Demo Code


//package com.java2s;

import android.view.animation.Animation;
import android.view.animation.LinearInterpolator;
import android.view.animation.RotateAnimation;
import android.widget.ImageView;

public class Main {

    public static Animation setRotationCenter(ImageView image) {
        int w = image.getDrawable().getIntrinsicWidth();
        int h = image.getDrawable().getIntrinsicHeight();
        RotateAnimation anim = new RotateAnimation(0f, 360f, w / 2f, h / 2f);
        anim.setInterpolator(new LinearInterpolator());
        anim.setRepeatCount(Animation.INFINITE);
        anim.setDuration(972);//from  w  w w  .j  av a2  s .  c o  m
        // image.startAnimation(anim);
        image.setAnimation(anim);
        // image.refreshDrawableState();
        return anim;
    }
}

Related Tutorials