Monday, 29 April 2013

Top to bottom animation android

Create anim folder in res.


slide_in_up.xml
--------------------

<?xml version="1.0" encoding="utf-8"?>

<translate
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:fromYDelta="0%p"
    android:toYDelta="-100%p"
    android:duration="@android:integer/config_longAnimTime"
    />

slide_out_up.xml
--------------------
<?xml version="1.0" encoding="utf-8"?>

<translate
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:fromYDelta="0%p"
    android:toYDelta="-100%p"
    android:duration="@android:integer/config_longAnimTime"
    />


Implement in java
---------------------

Intent intent = new Intent(this, Secondscreen.class);
startActivity(intent);
overridePendingTransition(R.anim.slide_in_up, R.anim.slide_out_up);

***********************************************************************************

For back button animation
-----------------------------

@Override
    public void onBackPressed() {
        super.onBackPressed();
      
        finish();
        overridePendingTransition(R.anim.slide_in_up, R.anim.slide_out_up);
    }



No comments:

Post a Comment