PowenKo, Android Tutorial 18-3, Ani, Changing the animation between Activities

November 22, 2011   ·   0 Comments

Screen Shot 2012-03-26 at 11.50.00 AM

only working sdk 2.0 version or later.

sample code: Tutorial_Activity_Animation20

package com.powenko;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

public class Tutorial_Activity_Animation20Activity extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
          Button b1 = (Button) findViewById(R.id.button1);
          b1.setOnClickListener(new Button.OnClickListener(){
                   @Override
         		public void onClick(View v)
                {
                    
                	   Intent intent = new Intent();
                       intent.setClass(Tutorial_Activity_Animation20Activity.this, page2.class);
          
                      
          
                       startActivity(intent);
                
                       
                       
                	   //Set the transition -> method available from Android 2.0 and beyond
                	   overridePendingTransition(R.anim.zoom_enter,R.anim.zoom_exit);
                }
                 });
             
    
    }
}
//Calls a new Activity  
startActivity(new Intent(this, NewActivity.class));  
  
//Set the transition -> method available from Android 2.0 and beyond  
overridePendingTransition(R.anim.zoom_enter,R.anim.zoom_exit);  

R\anim\zoom_enter.xml

<set xmlns:android="http://schemas.android.com/apk/res/android"
        android:interpolator="@android:anim/decelerate_interpolator">
    <scale android:fromXScale="2.0" android:toXScale="1.0"
           android:fromYScale="2.0" android:toYScale="1.0"
           android:pivotX="50%p" android:pivotY="50%p"
           android:duration="@android:integer/config_mediumAnimTime" />
</set>

R\anim\zoom_exit.xml

<set xmlns:android="http://schemas.android.com/apk/res/android"
        android:interpolator="@android:anim/decelerate_interpolator"
        android:zAdjustment="top">
    <scale android:fromXScale="1.0" android:toXScale=".5"
           android:fromYScale="1.0" android:toYScale=".5"
           android:pivotX="50%p" android:pivotY="50%p"
           android:duration="@android:integer/config_mediumAnimTime" />
    <alpha android:fromAlpha="1.0" android:toAlpha="0"
            android:duration="@android:integer/config_mediumAnimTime"/>
</set>
shareShare on FacebookShare on Google+Share on LinkedInEmail this to someonePrint this pageBuffer this pageDigg thisFlattr the authorShare on RedditPin on PinterestShare on StumbleUponShare on TumblrTweet about this on Twitter

By


Readers Comments (0)


You must be logged in to post a comment.

PowenKo’s Online Store

powenko_arduinoBook
Android7

Amazon

adsbygoogle

Recent Posts

Categories

Amazon