Android rotate animation between two activity?

前端 未结 1 2103
甜味超标
甜味超标 2020-12-08 09:23

How to put rotate animation between two activities.when is startactivity and next activity is start with rotate animation

1条回答
  •  北海茫月
    2020-12-08 09:39

    Here's a tutorial on how to add an animation when transistioning between two activities. However, instead of using a translate animation like in the article, you'll want to use a rotate animation. For more information on animations, checkout this documentation.

    Putting those two things together, here's what you need to do. First, where you make the call to start the new activity do this:

    //Calls a new Activity  
    startActivity(new Intent(this, NewActivity.class));  
    
    //Set the transition -> method available from Android 2.0 and beyond  
    overridePendingTransition(R.anim.rotate_out,R.anim.rotate_in);
    

    Then create the following two animations in your xml:

    rotate_out.xml

       
      
         
       
    
    

    rotate_in.xml

       
      
         
       
    
    

    You can play with the fromDegrees, toDegrees, and pivotX values to get exactly what you'd like.

    0 讨论(0)
提交回复
热议问题