Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

slide up xml animation on change activity in android

I read the below link before posting this.

How to apply slide animation between two activities in Android?

I need to know how to make activity slideup xml animation. like what they have done for fadein and fadeout.

like image 568
praveen kumar Avatar asked Aug 11 '12 05:08

praveen kumar


People also ask

What is transition animation in Android?

Android's transition framework allows you to animate all kinds of motion in your UI by simply providing the starting layout and the ending layout.

What does startActivity () method do?

To start an activity, use the method startActivity(intent) . This method is defined on the Context object which Activity extends. The following code demonstrates how you can start another activity via an intent. # Start the activity connect to the # specified class Intent i = new Intent(this, ActivityTwo.


3 Answers

The accepted answer isn't what the question was asking, which is animations that slide up from the bottom and slide out from the top.

pull_up_from_bottom.xml:

<?xml version="1.0" encoding="utf-8"?>
<translate xmlns:android="http://schemas.android.com/apk/res/android"
    android:duration="@android:integer/config_longAnimTime" 
    android:fromYDelta="100%"
    android:toYDelta="0%" />

push_out_to_bottom.xml:

<?xml version="1.0" encoding="utf-8"?>
<translate xmlns:android="http://schemas.android.com/apk/res/android"
    android:duration="@android:integer/config_longAnimTime"
    android:fromYDelta="0%"
    android:toYDelta="100%" />
like image 63
georgiecasey Avatar answered Oct 15 '22 18:10

georgiecasey


for slide_in xml :

<translate 
      xmlns:android="http://schemas.android.com/apk/res/android"
      android:duration="250" 
      android:fromXDelta="-100%p" 
      android:toXDelta="0%p">
</translate>

for slide_out xml:

<translate
      xmlns:android="http://schemas.android.com/apk/res/android" 
      android:duration="200" 
      android:fromXDelta="0" 
      android:toXDelta="100%p">
</translate>

Java code :

Intent intent = new Intent(this, newActivity.class);
startActivity(intent);
overridePendingTransition(R.anim.slide_in, R.anim.slide_out);

put both xml files in res/anim folder.

like image 31
Mansi Avatar answered Oct 15 '22 19:10

Mansi


This is what I was after:

res/anim/slide_up.xml

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

res/anim/slide_down.xml

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

res/anim/slide_down_reverse.xml

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

res/anim/slide_up_reverse.xml

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

YourActivity.kt

override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)

    setContentView(R.layout.your_layout)

    overridePendingTransition(R.anim.slide_up, R.anim.slide_down)
}

override fun finish() {
    super.finish()

    overridePendingTransition(R.anim.slide_down_reverse, R.anim.slide_up_reverse)
}
like image 45
Bitcoin Cash - ADA enthusiast Avatar answered Oct 15 '22 20:10

Bitcoin Cash - ADA enthusiast