Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to make Flip animation image in android?

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 3.68k
    Comment on it

     In the below example code, I have set the animation to an ImagView when you clicks on image, image will rotate 180 degrees from Y axis. Here first, I have added an ImageView within actvity_main.xml layout, after that I have created a flip.xml resource file within animator folder and here I have added flip animation attributes, Now see programming part, here I have used AnimatorSet class and load flip.xml  res. and used start() method for animation.


    You can see below example code it clearly describes How to make Flip animation image in android

     

    Step(1)-I have created flip.xml resource file within animator folder-

    <?xml version="1.0" encoding="utf-8"?>
        <set xmlns:android="http://schemas.android.com/apk/res/android" android:ordering="sequentially" >
            <objectAnimator
                android:duration="1000"
                android:propertyName="rotationY"
                android:valueFrom="0"
                android:valueTo="180" >
            </objectAnimator>
        
        </set>

     

    Step(2)-MainActivity-

    
         final ImageView imageView = (ImageView) findViewById(R.id.imageview);
                imageView.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        set=(AnimatorSet)AnimatorInflater.loadAnimator(MainActivity.this,R.animator.flip);
    
                        set.setTarget(imageView);
                        set.start();
                    }
                });
    
    

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: