Creating a 3D flip animation in Android using XML

后端 未结 8 1731
萌比男神i
萌比男神i 2020-12-22 20:25

I have created a 3D flip of a view using this android tutorial However, I have done it programmatically and I would like to do it all in xml, if possible. I am not talking

8条回答
  •  生来不讨喜
    2020-12-22 20:42

    Here is the answer, though it only works with 3.0 and above.

    1) Create a new resources folder called "animator".

    2) Create a new .xml file which I will call "flipping". Use the following xml code:

    
    
    
    

    No, the objectAnimator tags do not start with an uppercase "O".

    3) Start the animation with the following code:

    ObjectAnimator anim = (ObjectAnimator) AnimatorInflater.loadAnimator(mContext, R.animator.flipping); 
    anim.setTarget(A View Object reference goes here i.e. ImageView);
    anim.setDuration(3000);
    anim.start();
    

    I got all this from here.

提交回复
热议问题