Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.3k views
in Technique[技术] by (71.8m points)

android - Display Activity From Bottom to Top

I want to display one activity to another from bottom to top animation using Intent.

Given me some example for that like below

Intent i2 = new Intent(main.this, test.class);
startActivity(i2);

with animation bottom to top.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Define an animation in res/anim/slide_in_up.xml:

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

and another at res/anim/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"/>

Then apply these after to call startActivity:

Intent i2 = new Intent(main.this, test.class);
startActivity(i2);
overridePendingTransition( R.anim.slide_in_up, R.anim.slide_out_up );

There an introduction to Android animation here which may help you further.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...